Skip to content

ZOOKEEPER-5092: sequence numbers don't increment past Integer.MAX_VALUE - #2462

Open
kalayciburak wants to merge 1 commit into
apache:masterfrom
kalayciburak:ZOOKEEPER-5092
Open

kalayciburak wants to merge 1 commit into
apache:masterfrom
kalayciburak:ZOOKEEPER-5092

Conversation

@kalayciburak

Copy link
Copy Markdown

Summary

Sequential node names are a signed 32-bit parent cversion. The programmer guide says the counter overflows past 2147483647 and the next name is <path>-2147483648.

PrepRequestProcessor already computes that wrap (MAX_VALUE + 1 == Integer.MIN_VALUE) and puts it on the create txn. DataTree.createNode and setCversionPzxid then drop it: the fuzzy-snapshot guard only applies a cversion that is numerically larger. Integer.MIN_VALUE is not larger than Integer.MAX_VALUE, so the parent stays at 2147483647 and the next sequential create reuses that suffix.

The wrap from Integer.MAX_VALUE to Integer.MIN_VALUE is now treated as a forward step. Any other smaller value is still ignored, so fuzzy replay cannot rewind the counter.

This does not change the on-disk counter width. ZOOKEEPER-4706 (open, new 64-bit create modes) is a separate feature.

Test plan

  • mvn -pl zookeeper-server -am -Dtest=DataTreeTest#testCversionOverflowAdvances+testNoCversionRevert+testIncrementCversion -Dsurefire.failIfNoSpecifiedTests=false test (Java 17)
  • mvn -pl zookeeper-server checkstyle:check (0 violations)

Before the fix, testCversionOverflowAdvances failed with expected: <-2147483648> but was: <2147483647>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant