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

feat: add callback option when stale lock is reclaimed #106

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

albe
Copy link

@albe albe commented May 28, 2021

Closes #105

TODO:

  • Add tests
  • Add docs

@albe
Copy link
Author

albe commented May 28, 2021

One thing I'm not sure about is the race condition for the reclaiming now - if two processes start with a stale lock, then one starts to delete it, the other in the meantime acquires the lock and the second one then fails to acquire the lock, the callback will not be invoked and the information that a stale lock existed is lost.
If however the callback is invoked immediately after removing the stale lock, then multiple processes could invoke the onReclaimedStale (or whatever it will be called finally) callback, which is potentially unintended.
So can we make the "reclaiming" atomic? i.e. instead of "delete + acquire" just overwrite the existing lock?

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.

Feature Request: Provide an API to react on a stale lock that is reclaimed
1 participant