-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(recipe): prevent perpetual re-election if sequence node overflows #731
base: master
Are you sure you want to change the base?
Conversation
kazoo/tests/test_lock.py
Outdated
pyLock_predecessor = f"{pyLock_prefix}-0000000032" | ||
pyLock = f"{pyLock_prefix}-0000000031" | ||
pyLock_successor = f"{pyLock_prefix}-0000000030" | ||
children = ["hello", pyLock_predecessor, "world", pyLock, pyLock_successor] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
kazoo/tests/test_lock.py
Outdated
def test_get_predecessor_with_overflowed_sequence(self): | ||
"""Validate selection of predecessors with negative sequence. | ||
|
||
This can occur in case of an integer overflow, if the sequence counter is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (81 > 79 characters)
kazoo/tests/test_lock.py
Outdated
|
||
def test_get_predecessor_with_overflowed_sequence(self): | ||
"""Validate selection of predecessors with negative sequence. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line contains whitespace
kazoo/tests/test_lock.py
Outdated
client.get_children.return_value = children | ||
lock = Lock(client, "test") | ||
assert lock._get_predecessor(pyLock) == pyLock_predecessor | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blank line contains whitespace
kazoo/tests/test_lock.py
Outdated
pyLock_predecessor = f"{pyLock_prefix}0000000030" | ||
pyLock = f"{pyLock_prefix}0000000031" | ||
pyLock_successor = f"{pyLock_prefix}0000000032" | ||
children = ["hello", pyLock_predecessor, "world", pyLock, pyLock_successor] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
Once sequence node is incremented beyond 2147483647, the sequence overflows into the negative space. When getting predecessors, cast the node sequence from String to int before comparing. Closes python-zk#730
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #731 +/- ##
==========================================
- Coverage 96.73% 96.65% -0.09%
==========================================
Files 27 27
Lines 3556 3556
==========================================
- Hits 3440 3437 -3
- Misses 116 119 +3
☔ View full report in Codecov by Sentry. |
Once sequence node is incremented beyond 2147483647, the sequence overflows into the negative space. When getting predecessors, cast the node sequence from String to int before comparing.
Closes #730
Why is this needed?
Prevents perpetual re-election if sequence nodes is incremented beyond 2147483647. Previously the sequence node comparison was comparing two Strings, with this change the comparison is done with integers instead. This means that the only re-election due to an integer overflow will happen when incrementing from 2147483647 to -2147483648, but any subsequent increment will not result in a re-election.
Proposed Changes
Does this PR introduce any breaking change?
No