Repository navigation
Fix deadlock in proxy segment when propagating to write segment - #4206
Merged
Merged
Conversation
This caused a deadlock when used in conjunction with searches through the proxy, locking in a different order.
ffuugoo
approved these changes
May 9, 2024
generall
approved these changes
May 9, 2024
timvisee
added a commit
that referenced
this pull request
May 9, 2024
* Don't keep wrapped segment lock when propagating proxy changes This caused a deadlock when used in conjunction with searches through the proxy, locking in a different order. * When propagating, upgrade/downgrade wrapped segment lock back and forth * Switch to upgrading the wrapped segment read lock on demand * Annotate propagate function to prevent deadlocks in the future * Minor log refactoring * Add link to PR
Merged
This file contains hidden or 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
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.
Likely fixes: #4199
Fix a deadlock in the proxy segment. Locking in the
propagate_to_wrapped()and search functions conflict.The search function hold a lock on
deleted_pointsafter which it locked the wrapped segment. The propagation function did it the other way around.I fixed this by not keeping a write lock on the write segment for the whole duration of the
propagate_to_wrapped()function. Instead we now take an upgradable read lock and temporarily upgrade it on demand. An alternative would be to require mutable self on this function to ensure exclusive access to all locks, but I expect that to have a worse impact in terms of performance.The last two days I managed to reproduce the problem very reliably. With this fix I've tested for another two hours, and I haven't seen it since.
For future reference, I've been testing like this getting a deadlock on the first snapshot request about 75% of the time:
All Submissions:
devbranch. Did you create your branch fromdev?New Feature Submissions:
cargo +nightly fmt --allcommand prior to submission?cargo clippy --all --all-featurescommand?