fix(transaction): Properly store block cancel status (#3371)

This commit is contained in:
Vladislav 2024-07-24 14:05:00 +03:00 committed by GitHub
parent 37cb247cd4
commit f73c7d0e42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View file

@ -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);
}
}

View file

@ -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();
}

View file

@ -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;