[Commits] f7507f3b2: Fix an assertion failure with shared locks
revision-id: f7507f3b2a5a1c1952577f9277268450830b08ca (v5.8-3258-gf7507f3b2) parent(s): cdd8b09b9b4528dae3a6a4a667a9e23b1d4f61f1 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2021-02-01 21:51:38 +0300 message: Fix an assertion failure with shared locks Fix this scenario: trx1> acquire shared lock on $key trx2> acquire shared lock on the same $key trx1> attempt to acquire a unique lock on $key. --- .../lock/range/range_tree/lib/locktree/lock_request.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/utilities/transactions/lock/range/range_tree/lib/locktree/lock_request.cc b/utilities/transactions/lock/range/range_tree/lib/locktree/lock_request.cc index ec7bd04dc..1d061e4c6 100644 --- a/utilities/transactions/lock/range/range_tree/lib/locktree/lock_request.cc +++ b/utilities/transactions/lock/range/range_tree/lib/locktree/lock_request.cc @@ -6,6 +6,8 @@ /*====== This file is part of PerconaFT. +Modified to make locktree usable as a separate module and support shared +locks. Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. @@ -148,7 +150,13 @@ void lock_request::build_wait_graph(wfg *wait_graph, for (uint32_t i = 0; i < num_conflicts; i++) { TXNID conflicting_txnid = conflicts.get(i); lock_request *conflicting_request = find_lock_request(conflicting_txnid); - invariant(conflicting_txnid != m_txnid); + if (conflicting_txnid == m_txnid) { + // We can get here for example when TRX1 and TRX2 have a shared lock on + // a key, and then TRX1 tries to acquire an exclusive lock on that key. + // It will get a conflict (with TRX2) but + // iterate_and_get_overlapping_row_locks will return both locks. + continue; + } invariant(conflicting_request != this); if (conflicting_request) { bool already_exists = wait_graph->node_exists(conflicting_txnid);
participants (1)
-
psergey