Skip to content
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 extension failure issue #167

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sola92
Copy link

@sola92 sola92 commented Apr 25, 2022

Issue #166

The lock's timer should start counting after the acquisition reaches quorum, not before. Otherwise, the lock is unfairly penalized for long acquisition wait time, and its extensions subsequent fail.

Lock timer should start counting *after* acquisition reaches quorum, not before. Otherwise extensions fail because lock is deemed to be expired -- prematurely -- due to long intial wait for acquisition quorum.
@mike-marcacci mike-marcacci self-requested a review May 11, 2022 16:29
@@ -313,6 +312,8 @@ export default class Redlock extends EventEmitter {
settings
);

const start = Date.now();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You make a very good point here, but I don't think this implementation is safe: the intent is that the expiration on the JS object is either the same or earlier than the one in redis. This change gets the time after it succeeds and calculates an effective expiration that could exceed the actual guarantee.

That said, I completely agree that each new attempt should use a new "start" saved just before making the actual redis calls.

Copy link
Author

@sola92 sola92 May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Happy to close this out in favor of a better solution from your end

This was referenced Mar 9, 2023
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.

None yet

2 participants