Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions ydb/core/tx/columnshard/transactions/tx_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,14 +359,9 @@ void TTxController::FinishProposeOnComplete(const ui64 txId, const TActorContext
txOperator->SendReply(Owner, ctx);
}

bool TTxController::ITransactionOperator::SwitchState(const EStatus from, const EStatus to) {
if (!Status || Status == from) {
Status = to;
return true;
} else {
AFL_WARN(NKikimrServices::TX_COLUMNSHARD)("real_state", *Status)("expected", from);
return false;
}
void TTxController::ITransactionOperator::SwitchStateVerified(const EStatus from, const EStatus to) {
AFL_VERIFY(!Status || *Status == from)("error", "incorrect expected status")("real_state", *Status)("expected", from);
Status = to;
}

}
Expand Down
22 changes: 11 additions & 11 deletions ydb/core/tx/columnshard/transactions/tx_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class TTxController {
virtual void DoSendReply(TColumnShard& owner, const TActorContext& ctx) = 0;
virtual bool DoCheckAllowUpdate(const TFullTxInfo& currentTxInfo) const = 0;

[[nodiscard]] bool SwitchState(const EStatus from, const EStatus to);
void SwitchStateVerified(const EStatus from, const EStatus to);
TTxInfo& MutableTxInfo() {
return TxInfo;
}
Expand Down Expand Up @@ -237,9 +237,9 @@ class TTxController {
AFL_VERIFY(!onLoad);
ProposeStartInfo = TTxController::TProposeResult(NKikimrTxColumnShard::EResultStatus::ERROR, TStringBuilder() << "Error processing commit TxId# " << TxInfo.TxId
<< ". Parsing error");
AFL_VERIFY(SwitchState(EStatus::Created, EStatus::Failed));
SwitchStateVerified(EStatus::Created, EStatus::Failed);
} else {
AFL_VERIFY(SwitchState(EStatus::Created, EStatus::Parsed));
SwitchStateVerified(EStatus::Created, EStatus::Parsed);
}
if (onLoad) {
ProposeStartInfo = TTxController::TProposeResult(NKikimrTxColumnShard::EResultStatus::PREPARED, "success on iteration before restart");
Expand All @@ -251,9 +251,9 @@ class TTxController {
void SendReply(TColumnShard& owner, const TActorContext& ctx) {
AFL_VERIFY(!!ProposeStartInfo);
if (ProposeStartInfo->IsFail()) {
AFL_VERIFY(SwitchState(EStatus::Failed, EStatus::ReplySent));
SwitchStateVerified(EStatus::Failed, EStatus::ReplySent);
} else {
AFL_VERIFY(SwitchState(EStatus::ProposeFinishedOnComplete, EStatus::ReplySent));
SwitchStateVerified(EStatus::ProposeFinishedOnComplete, EStatus::ReplySent);
}
return DoSendReply(owner, ctx);
}
Expand All @@ -262,29 +262,29 @@ class TTxController {
AFL_VERIFY(!ProposeStartInfo);
ProposeStartInfo = DoStartProposeOnExecute(owner, txc);
if (ProposeStartInfo->IsFail()) {
AFL_VERIFY(SwitchState(EStatus::Parsed, EStatus::Failed));
SwitchStateVerified(EStatus::Parsed, EStatus::Failed);
} else {
AFL_VERIFY(SwitchState(EStatus::Parsed, EStatus::ProposeStartedOnExecute));
SwitchStateVerified(EStatus::Parsed, EStatus::ProposeStartedOnExecute);
}
return !GetProposeStartInfoVerified().IsFail();
}
void StartProposeOnComplete(TColumnShard& owner, const TActorContext& ctx) {
AFL_VERIFY(SwitchState(EStatus::ProposeStartedOnExecute, EStatus::ProposeStartedOnComplete));
SwitchStateVerified(EStatus::ProposeStartedOnExecute, EStatus::ProposeStartedOnComplete);
AFL_VERIFY(IsAsync());
return DoStartProposeOnComplete(owner, ctx);
}
void FinishProposeOnExecute(TColumnShard& owner, NTabletFlatExecutor::TTransactionContext& txc) {
AFL_VERIFY(SwitchState(EStatus::ProposeStartedOnComplete, EStatus::ProposeFinishedOnExecute));
SwitchStateVerified(EStatus::ProposeStartedOnComplete, EStatus::ProposeFinishedOnExecute);
AFL_VERIFY(IsAsync());
return DoFinishProposeOnExecute(owner, txc);
}
void FinishProposeOnComplete(TColumnShard& owner, const TActorContext& ctx) {
if (IsFail()) {
AFL_VERIFY(Status == EStatus::Failed);
} else if (DoIsAsync()) {
AFL_VERIFY(SwitchState(EStatus::ProposeFinishedOnExecute, EStatus::ProposeFinishedOnComplete));
SwitchStateVerified(EStatus::ProposeFinishedOnExecute, EStatus::ProposeFinishedOnComplete);
} else {
AFL_VERIFY(SwitchState(EStatus::ProposeStartedOnExecute, EStatus::ProposeFinishedOnComplete));
SwitchStateVerified(EStatus::ProposeStartedOnExecute, EStatus::ProposeFinishedOnComplete);
}
return DoFinishProposeOnComplete(owner, ctx);
}
Expand Down