Skip to content

Acquire client lock in heartbeat thread before sending requests #2620

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

Merged
merged 2 commits into from
May 15, 2025

Conversation

dpkp
Copy link
Owner

@dpkp dpkp commented May 14, 2025

Both lookup_coordinator and _send_heartbeat_request make client api calls that require locking. The tricky part of the heartbeat run loop is that we need to always acquire client lock first and coordinator lock second (to avoid deadlocks), but we also cannot hold the client lock while calling coordinator lock.wait() . To make this easier, switch from context managers to try / finally and catch any RuntimeError if the client lock has already been released when we reach the finally block.

@dpkp dpkp merged commit 8a424e9 into master May 15, 2025
33 of 34 checks passed
@dpkp dpkp deleted the dpkp/heartbeat-thread-locks branch May 15, 2025 20:27
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.

1 participant