mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 18:05:44 +02:00
fix(transaction): Properly store block cancel status (#3371)
This commit is contained in:
parent
37cb247cd4
commit
f73c7d0e42
3 changed files with 8 additions and 3 deletions
|
@ -1568,7 +1568,7 @@ void ServerFamily::CancelBlockingOnThread(std::function<OpStatus(ArgSlice)> stat
|
|||
auto cb = [status_cb](unsigned thread_index, util::Connection* conn) {
|
||||
if (auto fcntx = static_cast<facade::Connection*>(conn)->cntx(); fcntx) {
|
||||
auto* cntx = static_cast<ConnectionContext*>(fcntx);
|
||||
if (cntx->transaction && cntx->blocked) {
|
||||
if (cntx->transaction) {
|
||||
cntx->transaction->CancelBlocking(status_cb);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1178,7 +1178,8 @@ OpStatus Transaction::WaitOnWatch(const time_point& tp, WaitKeysProvider wkeys_p
|
|||
if (status == cv_status::timeout) {
|
||||
result = OpStatus::TIMED_OUT;
|
||||
} else if (coordinator_state_ & COORD_CANCELLED) {
|
||||
result = local_result_;
|
||||
DCHECK_GT(block_cancel_result_, OpStatus::OK);
|
||||
result = block_cancel_result_;
|
||||
}
|
||||
|
||||
// If we don't follow up with an "action" hop, we must clean up manually on all shards.
|
||||
|
@ -1412,7 +1413,8 @@ void Transaction::CancelBlocking(std::function<OpStatus(ArgSlice)> status_cb) {
|
|||
return;
|
||||
|
||||
coordinator_state_ |= COORD_CANCELLED;
|
||||
local_result_ = status;
|
||||
// don't use local_result_ because it can be overwirtten if we cancel ahead
|
||||
block_cancel_result_ = status;
|
||||
blocking_barrier_.Close();
|
||||
}
|
||||
|
||||
|
|
|
@ -630,6 +630,9 @@ class Transaction {
|
|||
|
||||
// Barrier for waking blocking transactions that ensures exclusivity of waking operation.
|
||||
BatonBarrier blocking_barrier_{};
|
||||
// Stores status if COORD_CANCELLED was set. Apart from cancelled, it can be moved for cluster
|
||||
// changes
|
||||
OpStatus block_cancel_result_ = OpStatus::OK;
|
||||
|
||||
// Transaction coordinator state, written and read by coordinator thread.
|
||||
uint8_t coordinator_state_ = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue