-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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: deadlock in balance shutdown #14125
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bukata-sa
force-pushed
the
fix/balance_deadlock
branch
from
August 14, 2024 18:10
6684622
to
8264191
Compare
bukata-sa
force-pushed
the
fix/balance_deadlock
branch
from
August 14, 2024 18:14
8264191
to
520621a
Compare
bukata-sa
force-pushed
the
fix/balance_deadlock
branch
from
August 14, 2024 18:15
520621a
to
fc19025
Compare
jmank88
previously approved these changes
Aug 14, 2024
george-dorin
previously approved these changes
Aug 15, 2024
bukata-sa
force-pushed
the
fix/balance_deadlock
branch
2 times, most recently
from
August 15, 2024 09:11
695c2e0
to
9d774b6
Compare
bukata-sa
force-pushed
the
fix/balance_deadlock
branch
from
August 15, 2024 09:15
9d774b6
to
bd39d9f
Compare
Quality Gate passedIssues Measures |
george-dorin
approved these changes
Aug 15, 2024
jmank88
approved these changes
Aug 15, 2024
This was referenced Aug 18, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Calling
bm.sleeperTask.IfStarted
->bm.sleeperTask.WakeUp
uses two read locks, whilebm.sleeperTask.WakeUpIfStarted
uses only one read lockWhy
From time to time balancer monitor can't shutdown. Because there can be exclusive lock (taken on
service.Stop
) between these two read locks.Imagine: (g1 and g2 - goroutines)
g1:OnNewLongestChain -> g1:bm.sleeperTask.IfStarted (RLock1 taken) -> g2:bm.sleeperTask.Stop (WLock tried to take, but blocked, waiting for RLock1) -> g1:bm.sleeperTask.WakeUp (RLock2 tried to be taken, but blocked because have pending WLock) => deadlock (RLock2 -(waits)> WLock -(waits)> RLock1)
Extra
I had no idea before, but if you have RLock, then pending WLock, then you can't have new RLocksThis test fails
Requires Dependencies
smartcontractkit/chainlink-common#706
Resolves Dependencies
#13647