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
pd: fix a deadlock #1768
pd: fix a deadlock #1768
Conversation
can we add a test for it? For the next write, we use try_write to check the lock is still locked. |
LGTM |
I think compiler will translate it to
. |
src/util/mod.rs
Outdated
@@ -553,4 +553,30 @@ mod tests { | |||
defer!(assert!(!sp.load(Ordering::SeqCst))); | |||
should_panic.store(false, Ordering::SeqCst); | |||
} | |||
|
|||
#[test] | |||
fn test_rwlock() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_rwlock_deadlock
LGTM |
3f64ef9
to
e78b645
Compare
PTAL @BusyJay |
LGTM |
Though I don't think the test case is related to the bug. |
FYI, may be solved in RFC#2094(non-lexical lifetimes) |
This PR fix deadlock pitfall. Reading then writing a
RwLock
in a match block will cause a deadlock.Demo:
Playground