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

Prevent runaway lock timeout #280

Merged
merged 1 commit into from
Apr 10, 2024
Merged

Prevent runaway lock timeout #280

merged 1 commit into from
Apr 10, 2024

Conversation

dfarr
Copy link
Member

@dfarr dfarr commented Apr 10, 2024

On lock heartbeat we set the new lock timeout as follows:

timeout = timeout + expiry

However, heartbeat requests may occur more frequently than once each time the lock is set to expire. For example, here is a lock that is acquired at t=0 with an initial timeout of t=60000 (one minute) where we heartbeat every 15s. The intent is for the timeout to always stay one minute ahead of the most recent heartbeat request, but we see it runaway.

heartbeat expiry_in_ms timeout timeout' (after pr)
60,000 60,000 60,000
15,000 60,000 120,000 75,000
30,000 60,000 180,000 90,000
45,000 60,000 240,000 105,000
60,000 60,000 300,000 120,000

This change is achieved by changing the calculation for the new timeout to:

timeout = tick_time + expiry

Currently on lock heartbeats, we add the expiry time to the timeout
time. Because heartbeat frequency is not locked to the timeout
time, this causes lock timeouts to "runaway" on each heartbeat.
This change adds the expiry time to the current tick time, which
prevents the runaway.
Copy link

codecov bot commented Apr 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.27%. Comparing base (6a41367) to head (147ccea).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #280   +/-   ##
=======================================
  Coverage   62.27%   62.27%           
=======================================
  Files         113      113           
  Lines        9706     9707    +1     
=======================================
+ Hits         6044     6045    +1     
  Misses       3169     3169           
  Partials      493      493           

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

@dfarr dfarr requested a review from guergabo April 10, 2024 00:20
Copy link
Contributor

@guergabo guergabo left a comment

Choose a reason for hiding this comment

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

lgtm

@dfarr dfarr merged commit b67b3a9 into main Apr 10, 2024
5 checks passed
@dfarr dfarr deleted the fix/runaway-lock-timeout branch April 10, 2024 16:07
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.

2 participants