Skip to content

Commit 8238e87

Browse files
ivanmorozov333marsaly79
authored andcommitted
Clean plan queue item (ydb-platform#3849)
1 parent b3ef615 commit 8238e87

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

ydb/core/tx/columnshard/columnshard__progress_tx.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class TColumnShard::TTxProgressTx : public TTransactionBase<TColumnShard> {
3030
// Process a single transaction at the front of the queue
3131
auto plannedItem = Self->ProgressTxController->StartPlannedTx();
3232
if (!!plannedItem) {
33+
PlannedQueueItem.emplace(plannedItem->PlanStep, plannedItem->TxId);
3334
ui64 step = plannedItem->PlanStep;
3435
ui64 txId = plannedItem->TxId;
3536
LastCompletedTx = NOlap::TSnapshot(step, txId);
@@ -57,6 +58,9 @@ class TColumnShard::TTxProgressTx : public TTransactionBase<TColumnShard> {
5758
if (TxOperator) {
5859
TxOperator->Complete(*Self, ctx);
5960
}
61+
if (PlannedQueueItem) {
62+
Self->GetProgressTxController().CompleteRunningTx(*PlannedQueueItem);
63+
}
6064
if (LastCompletedTx) {
6165
Self->LastCompletedTx = std::max(*LastCompletedTx, Self->LastCompletedTx);
6266
}
@@ -67,6 +71,7 @@ class TColumnShard::TTxProgressTx : public TTransactionBase<TColumnShard> {
6771
TTxController::ITransactionOperatior::TPtr TxOperator;
6872
const ui32 TabletTxNo;
6973
std::optional<NOlap::TSnapshot> LastCompletedTx;
74+
std::optional<TTxController::TPlanQueueItem> PlannedQueueItem;
7075
};
7176

7277
void TColumnShard::EnqueueProgressTx(const TActorContext& ctx) {

ydb/core/tx/columnshard/transactions/tx_controller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void TTxController::FinishPlannedTx(const ui64 txId, NTabletFlatExecutor::TTrans
195195
}
196196

197197
void TTxController::CompleteRunningTx(const TPlanQueueItem& txItem) {
198-
RunningQueue.erase(txItem);
198+
AFL_VERIFY(RunningQueue.erase(txItem))("info", txItem.DebugString());
199199
}
200200

201201
std::optional<TTxController::TPlanQueueItem> TTxController::GetPlannedTx() const {

ydb/core/tx/columnshard/transactions/tx_controller.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class TTxController {
2424
inline bool operator<(const TPlanQueueItem& rhs) const {
2525
return Step < rhs.Step || (Step == rhs.Step && TxId < rhs.TxId);
2626
}
27+
28+
TString DebugString() const {
29+
return TStringBuilder() << "step=" << Step << ";txId=" << TxId << ";";
30+
}
2731
};
2832

2933
struct TBasicTxInfo {

0 commit comments

Comments
 (0)