Skip to content

Commit

Permalink
Clean plan queue item (#3849)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanmorozov333 authored Apr 18, 2024
1 parent 54aeac4 commit b22ab25
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ydb/core/tx/columnshard/columnshard__progress_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class TColumnShard::TTxProgressTx : public TTransactionBase<TColumnShard> {
// Process a single transaction at the front of the queue
auto plannedItem = Self->ProgressTxController->StartPlannedTx();
if (!!plannedItem) {
PlannedQueueItem.emplace(plannedItem->PlanStep, plannedItem->TxId);
ui64 step = plannedItem->PlanStep;
ui64 txId = plannedItem->TxId;
LastCompletedTx = NOlap::TSnapshot(step, txId);
Expand Down Expand Up @@ -57,6 +58,9 @@ class TColumnShard::TTxProgressTx : public TTransactionBase<TColumnShard> {
if (TxOperator) {
TxOperator->Complete(*Self, ctx);
}
if (PlannedQueueItem) {
Self->GetProgressTxController().CompleteRunningTx(*PlannedQueueItem);
}
if (LastCompletedTx) {
Self->LastCompletedTx = std::max(*LastCompletedTx, Self->LastCompletedTx);
}
Expand All @@ -67,6 +71,7 @@ class TColumnShard::TTxProgressTx : public TTransactionBase<TColumnShard> {
TTxController::ITransactionOperatior::TPtr TxOperator;
const ui32 TabletTxNo;
std::optional<NOlap::TSnapshot> LastCompletedTx;
std::optional<TTxController::TPlanQueueItem> PlannedQueueItem;
};

void TColumnShard::EnqueueProgressTx(const TActorContext& ctx) {
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/tx/columnshard/transactions/tx_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void TTxController::FinishPlannedTx(const ui64 txId, NTabletFlatExecutor::TTrans
}

void TTxController::CompleteRunningTx(const TPlanQueueItem& txItem) {
RunningQueue.erase(txItem);
AFL_VERIFY(RunningQueue.erase(txItem))("info", txItem.DebugString());
}

std::optional<TTxController::TPlanQueueItem> TTxController::GetPlannedTx() const {
Expand Down
4 changes: 4 additions & 0 deletions ydb/core/tx/columnshard/transactions/tx_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class TTxController {
inline bool operator<(const TPlanQueueItem& rhs) const {
return Step < rhs.Step || (Step == rhs.Step && TxId < rhs.TxId);
}

TString DebugString() const {
return TStringBuilder() << "step=" << Step << ";txId=" << TxId << ";";
}
};

struct TBasicTxInfo {
Expand Down

0 comments on commit b22ab25

Please sign in to comment.