Skip to content

Commit

Permalink
[fix][store] Fix PessimisticRollback remove lock in prewrite stage.
Browse files Browse the repository at this point in the history
Signed-off-by: Ketor <d.ketor@gmail.com>
  • Loading branch information
ketor authored and rock-git committed Apr 23, 2024
1 parent eb49895 commit 3fce387
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/engine/txn_engine_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1564,11 +1564,12 @@ butil::Status TxnEngineHelper::PessimisticRollback(RawEnginePtr raw_engine, std:
}

if (!lock_info.primary_lock().empty()) {
if (lock_info.for_update_ts() == 0) {
// this is a optimistic lock, return lock_info
DINGO_LOG(ERROR) << fmt::format("[txn][region({})] PessimisticRollback,", region->Id())
<< ", key: " << Helper::StringToHex(key)
<< " is locked by optimistic lock, lock_info: " << lock_info.ShortDebugString();
if (lock_info.lock_type() != pb::store::Op::Lock) {
// this is a optimistic lock or pessimistic lock in prewrite stage, return lock_info
DINGO_LOG(WARNING) << fmt::format("[txn][region({})] PessimisticRollback,", region->Id())
<< ", key: " << Helper::StringToHex(key)
<< " is locked by optimistic lock or pessimistic lock in prewrite stage, lock_info: "
<< lock_info.ShortDebugString();
// return lock_info
*response->add_txn_result()->mutable_locked() = lock_info;
continue;
Expand Down

0 comments on commit 3fce387

Please sign in to comment.