From c1cd2acd49eed8d1715eb4f1df4ac8277af356dd Mon Sep 17 00:00:00 2001 From: ekexium Date: Tue, 12 Jan 2021 17:44:29 +0800 Subject: [PATCH 1/2] add some comment for deadlock Signed-off-by: ekexium --- src/pd/retry.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pd/retry.rs b/src/pd/retry.rs index d2a0da7..798d845 100644 --- a/src/pd/retry.rs +++ b/src/pd/retry.rs @@ -54,6 +54,8 @@ macro_rules! retry { let stats = pd_stats($tag); let mut last_err = Ok(()); for _ in 0..LEADER_CHANGE_RETRY { + // use the block here to drop the guard of the read lock, + // otherwise `reconnect` will try to acquire the write lock and results in a deadlock let res = { let $cluster = &$self.cluster.read().await.0; let res = $call.await; From 32f0a0213e166a4b7345d37e16ed26cb243556a3 Mon Sep 17 00:00:00 2001 From: ekexium Date: Tue, 12 Jan 2021 18:23:30 +0800 Subject: [PATCH 2/2] make CheckLevel public Signed-off-by: ekexium --- src/lib.rs | 2 +- src/transaction/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 2104b4e..8df0dca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -110,7 +110,7 @@ pub use crate::request::RetryOptions; pub use crate::timestamp::{Timestamp, TimestampExt}; #[doc(inline)] pub use crate::transaction::{ - Client as TransactionClient, Snapshot, Transaction, TransactionOptions, + CheckLevel, Client as TransactionClient, Snapshot, Transaction, TransactionOptions, }; #[doc(inline)] pub use config::Config; diff --git a/src/transaction/mod.rs b/src/transaction/mod.rs index bf37880..d2eb03a 100644 --- a/src/transaction/mod.rs +++ b/src/transaction/mod.rs @@ -11,7 +11,7 @@ pub use client::Client; pub(crate) use lock::{resolve_locks, HasLocks}; pub use snapshot::Snapshot; -pub use transaction::{Transaction, TransactionOptions}; +pub use transaction::{CheckLevel, Transaction, TransactionOptions}; mod buffer; mod client;