Skip to content

recipe(lock): retry lock cleanup #760

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

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

Conversation

jeblair
Copy link
Contributor

@jeblair jeblair commented Feb 26, 2025

If a non-blocking lock fails to acquire the lock, and then encounters a KazooError (due to a suspended session), the _best_effort_cleanup method will swallow the exception and control will return without the lock contender node being deleted. If the session resumes (does not expire) then we will have left a lock contender in place, which will eventually become an orphaned, stuck lock once the original actor releases it.

To correct this, retry deleting the lock contender in all cases. Due to the importance of this, we ignore the supplied timeout (in case the aquire method was called with a timeout) and retry forever.

Closes: #732

If a non-blocking lock fails to acquire the lock, and then encounters
a KazooError (due to a suspended session), the _best_effort_cleanup method
will swallow the exception and control will return without the lock
contender node being deleted.  If the session resumes (does not expire)
then we will have left a lock contender in place, which will eventually
become an orphaned, stuck lock once the original actor releases it.

To correct this, retry deleting the lock contender in all cases.  Due
to the importance of this, we ignore the supplied timeout (in case the
aquire method was called with a timeout) and retry forever.

Closes: python-zk#732
Copy link

codecov bot commented Feb 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.76%. Comparing base (86e69f2) to head (019f74e).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #760      +/-   ##
==========================================
+ Coverage   96.67%   96.76%   +0.08%     
==========================================
  Files          27       27              
  Lines        3553     3555       +2     
==========================================
+ Hits         3435     3440       +5     
+ Misses        118      115       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@StephenSorriaux
Copy link
Member

Hello,

Thank you for the PR. May I ask if a test case can cover this change?

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.

Non-blocking lock acquisition failure can "leak" the ephemeral lock node.
2 participants