Conversation
In even-node configurations (e.g. N=2, quorumSize=2), a tie vote (1 for, 1 against) would result in all votes being collected without either side reaching quorumSize. Previously, only done() was invoked, leaving the outer attempt Promise permanently pending. This fix resolves the attempt with vote 'against' once all votes are in without reaching quorum.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
This PR resolves several edge-case flaws and behavioral inconsistencies in
Redlockandusing():Lock Validity Check on Acquisition & Extension (F1, F5):
acquire()andextend()to throw anExecutionErrorand release acquired instances ifDate.now() >= expiration, preventing returning expired locks.Prevent Self-Blocking during Retries (F2):
ACQUIRE_SCRIPT, allow acquiring/refreshing if the key exists with the same value as the current request.Timer Leak in
using()(F6):using()to ensure that whenroutinecompletes, in-flight extension callbacks will not schedule subsequent timers.using()finishes.Error Handling & Abort Preservation in
using()(F7):routinethrows an error, that business error is now preserved rather than being masked by a failedlock.release().signal.aborted),signal.erroris prioritized over secondary cleanup errors.Settings Pass-Through:
Lock.prototype.extendnow accepts optionalsettings, allowing per-call settings inusing()(such asretryCount) to be honored during lock extensions.Testing
src/regression.test.tscovering all 5 areas above.npm run build && npm test).