Skip to content

Commit

Permalink
chore(transaction): Don't call GetLocalMask from blocking controller (#…
Browse files Browse the repository at this point in the history
…2715)

chore: remove reliance on GetLocalMask in BlockingController
  • Loading branch information
dranikpg authored Mar 12, 2024
1 parent 9ccf2b9 commit 4a9f816
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
17 changes: 5 additions & 12 deletions src/server/blocking_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,10 @@ bool BlockingController::DbWatchTable::AddAwakeEvent(string_view key) {
// Removes tx from its watch queues if tx appears there.
void BlockingController::FinalizeWatched(ArgSlice args, Transaction* tx) {
DCHECK(tx);
VLOG(1) << "FinalizeBlocking [" << owner_->shard_id() << "]" << tx->DebugId();

ShardId sid = owner_->shard_id();

VLOG(1) << "FinalizeBlocking [" << sid << "]" << tx->DebugId();

uint16_t local_mask = tx->GetLocalMask(sid);
bool is_awakened = local_mask & Transaction::AWAKED_Q;

if (is_awakened)
awakened_transactions_.erase(tx);
bool removed = awakened_transactions_.erase(tx);
DCHECK(!removed || (tx->GetLocalMask(owner_->shard_id()) & Transaction::AWAKED_Q));

auto dbit = watched_dbs_.find(tx->GetDbIndex());

Expand All @@ -143,9 +137,8 @@ void BlockingController::FinalizeWatched(ArgSlice args, Transaction* tx) {
// in case those keys still exist.
for (string_view key : args) {
bool removed_awakened = wt.UnwatchTx(key, tx);
if (removed_awakened) {
CHECK(is_awakened) << tx->DebugId() << " " << key << " " << local_mask;
}
CHECK(!removed_awakened || removed)
<< tx->DebugId() << " " << key << " " << tx->GetLocalMask(owner_->shard_id());
}

if (wt.queue_map.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/engine_shard_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ void EngineShard::PollExecution(const char* context, Transaction* trans) {
// If the transaction concluded, it must remove itself from the tx queue.
// Otherwise it is required to stay there to keep the relative order.
if (is_ooo && !trans->IsMulti())
DCHECK_EQ(keep, trans->GetLocalTxqPos(sid) != TxQueue::kEnd);
DCHECK_EQ(keep, trans->DEBUG_GetTxqPosInShard(sid) != TxQueue::kEnd);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/server/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,6 @@ class Transaction {
// Get OpArgs for specific shard
OpArgs GetOpArgs(EngineShard* shard) const;

uint32_t GetLocalTxqPos(ShardId sid) const {
return shard_data_[SidToId(sid)].pq_pos;
}

TxId txid() const {
return txid_;
}
Expand Down Expand Up @@ -356,6 +352,10 @@ class Transaction {
// Print in-dept failure state for debugging.
std::string DEBUG_PrintFailState(ShardId sid) const;

uint32_t DEBUG_GetTxqPosInShard(ShardId sid) const {
return shard_data_[SidToId(sid)].pq_pos;
}

private:
// Holds number of locks for each IntentLock::Mode: shared and exlusive.
struct LockCnt {
Expand Down

0 comments on commit 4a9f816

Please sign in to comment.