1
0
Fork 0
mirror of https://github.com/dragonflydb/dragonfly.git synced 2024-12-14 11:58:02 +00:00

chore(transaction): Don't call GetLocalMask from blocking controller (#2715)

chore: remove reliance on GetLocalMask in BlockingController
This commit is contained in:
Vladislav 2024-03-12 11:53:41 +03:00 committed by GitHub
parent 9ccf2b9871
commit 4a9f816106
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 17 deletions

View file

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

View file

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

View file

@ -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_;
}
@ -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 {