Lock recipe sorts sequenced children incorrectly
------------------------------------------------

                 Key: ZOOKEEPER-1329
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1329
             Project: ZooKeeper
          Issue Type: Bug
          Components: recipes
    Affects Versions: 3.3.3
         Environment: Mac OS X Version 10.6.8
Darwin emcclure-lt-mac.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 
16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
Homebrew 0.8
            Reporter: Evan McClure


The lock recipe sorts sequenced children lexicographically.  When the sequence 
number wraps, a lexicographical comparison will always place 2147483648 ahead 
of -2147483649, place -2147483648 ahead of -2147483649, and place -1 ahead of 
-2.  Clearly, we want 2147483648 < -2147483649, -2147483649 < -2147483648, and 
-2 placed ahead of -1, since those sequence numbers were generated in that 
order.

I suggest that the sequence numbers be converted to unsigned numbers before 
being compared in the comparison functor that gets passed to qsort().

This leaves us with another issue.  When comparing unsigned sequence numbers, 
there is a slim chance that 4294967296 < 0.  So, I suggest that a fudge range 
be used--say, the number of nodes in the quorum * some fudge factor--in order 
to handle this comparison.

Please close this if I'm way off base here.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to