Skip to content

Commit 9804db9

Browse files
committed
chore: get rid of redundant argument
Signed-off-by: Roman Gershman <roman@dragonflydb.io>
1 parent dc421a5 commit 9804db9

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

src/server/engine_shard.cc

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,11 @@ void EngineShard::PollExecution(const char* context, Transaction* trans) {
614614
continuation_trans_ = nullptr;
615615
}
616616

617-
string dbg_id;
618617
bool update_stats = false;
619618

620-
auto run = [this, &dbg_id, &update_stats](Transaction* tx, bool is_ooo) -> bool /* keep */ {
621-
dbg_id = VLOG_IS_ON(1) ? tx->DebugId() : "";
622-
bool concluding = tx->RunInShard(this, is_ooo);
619+
auto run = [this, &update_stats](Transaction* tx, bool is_ooo) -> bool /* concluding */ {
623620
update_stats = true;
624-
return !concluding;
621+
return tx->RunInShard(this, is_ooo);
625622
};
626623

627624
// Check the currently running transaction, we have to handle it first until it concludes
@@ -632,9 +629,7 @@ void EngineShard::PollExecution(const char* context, Transaction* trans) {
632629

633630
if ((is_self && disarmed) || continuation_trans_->DisarmInShard(sid)) {
634631
auto bc = continuation_trans_->GetNamespace().GetBlockingController(shard_id_);
635-
if (bool keep = run(continuation_trans_, false); !keep) {
636-
// if this holds, we can remove this check altogether.
637-
DCHECK(continuation_trans_ == nullptr);
632+
if (bool concludes = run(continuation_trans_, false); concludes) {
638633
continuation_trans_ = nullptr;
639634
}
640635
if (bc && bc->HasAwakedTransaction()) {
@@ -677,25 +672,28 @@ void EngineShard::PollExecution(const char* context, Transaction* trans) {
677672
DCHECK_LT(committed_txid_, txid); // strictly increasing when processed via txq
678673
committed_txid_ = txid;
679674

680-
if (bool keep = run(head, false); keep)
675+
DCHECK(!continuation_trans_); // while() check above ensures this.
676+
if (bool concludes = run(head, false); !concludes) {
681677
continuation_trans_ = head;
678+
}
682679
}
683680

684681
// If we disarmed, but didn't find ourselves in the loop, run now.
685682
if (trans && disarmed) {
686683
DCHECK(trans != head);
687684
DCHECK(trans_mask & (Transaction::OUT_OF_ORDER | Transaction::SUSPENDED_Q));
685+
CHECK(trans != continuation_trans_);
688686

689687
bool is_ooo = trans_mask & Transaction::OUT_OF_ORDER;
690-
bool keep = run(trans, is_ooo);
691-
if (is_ooo && !keep) {
688+
bool concludes = run(trans, is_ooo);
689+
if (is_ooo && concludes) {
692690
stats_.tx_ooo_total++;
693691
}
694692

695693
// If the transaction concluded, it must remove itself from the tx queue.
696694
// Otherwise it is required to stay there to keep the relative order.
697695
if (is_ooo && !trans->IsMulti())
698-
DCHECK_EQ(keep, trans->DEBUG_GetTxqPosInShard(sid) != TxQueue::kEnd);
696+
LOG_IF(DFATAL, concludes != (trans->DEBUG_GetTxqPosInShard(sid) == TxQueue::kEnd));
699697
}
700698
if (update_stats) {
701699
CacheStats();

src/server/transaction.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,6 @@ bool Transaction::RunInShard(EngineShard* shard, bool txq_ooo) {
591591

592592
bool was_suspended = sd.local_mask & SUSPENDED_Q;
593593
bool awaked_prerun = sd.local_mask & AWAKED_Q;
594-
595594
IntentLock::Mode mode = LockMode();
596595

597596
DCHECK(IsGlobal() || (sd.local_mask & KEYLOCK_ACQUIRED) || (multi_ && multi_->mode == GLOBAL));

src/server/transaction.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ class Transaction {
207207

208208
// Called by engine shard to execute a transaction hop.
209209
// txq_ooo is set to true if the transaction is running out of order
210-
// not as the tx queue head.
211-
// Returns true if the transaction continues running in the thread
210+
// not as the tx queue head. Returns true if the transaction concludes.
212211
bool RunInShard(EngineShard* shard, bool txq_ooo);
213212

214213
// Registers transaction into watched queue and blocks until a) either notification is received.

0 commit comments

Comments
 (0)