Skip to content

Commit

Permalink
txn: try to fix the deadlock caused by scan lock(#16342) (#16343)
Browse files Browse the repository at this point in the history
ref #16340

Try to fix the possible deadlock caused by scan lock.

Signed-off-by: cfzjywxk <cfzjywxk@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
cfzjywxk and ti-chi-bot[bot] authored Jan 10, 2024
1 parent cf687da commit 485db67
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/storage/mvcc/reader/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,15 @@ impl<S: EngineSnapshot> MvccReader<S> {
{
if let Some(txn_ext) = self.snapshot.ext().get_txn_ext() {
let begin_instant = Instant::now();
let res = match self.check_term_version_status(&txn_ext.pessimistic_locks.read()) {
let pessimistic_locks_guard = txn_ext.pessimistic_locks.read();
let res = match self.check_term_version_status(&pessimistic_locks_guard) {
Ok(_) => {
// Scan locks within the specified range and filter by max_ts.
Ok(txn_ext
.pessimistic_locks
.read()
.scan_locks(start_key, end_key, filter, scan_limit))
// Scan locks within the specified range and filter.
Ok(pessimistic_locks_guard.scan_locks(start_key, end_key, filter, scan_limit))
}
Err(e) => Err(e),
};
drop(pessimistic_locks_guard);
let elapsed = begin_instant.saturating_elapsed();
SCAN_LOCK_READ_TIME_VEC
.get(source)
Expand Down

0 comments on commit 485db67

Please sign in to comment.