forked from ydb-platform/ydb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Base transaction class for all propose operations (ydb-platform#2208)
Co-authored-by: nsofya <nsofya@yandex.ru>
- Loading branch information
Showing
9 changed files
with
157 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
ydb/core/tx/columnshard/transactions/propose_transaction_base.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "propose_transaction_base.h" | ||
|
||
#include <ydb/core/tx/columnshard/columnshard_impl.h> | ||
|
||
|
||
namespace NKikimr::NColumnShard { | ||
|
||
void TProposeTransactionBase::ProposeTransaction(const TTxController::TBasicTxInfo& txInfo, const TString& txBody, const TActorId source, const ui64 cookie, TTransactionContext& txc) { | ||
auto txOperator = TTxController::ITransactionOperatior::TFactory::MakeHolder(txInfo.TxKind, TTxController::TTxInfo(txInfo.TxKind, txInfo.TxId)); | ||
if (!txOperator || !txOperator->Parse(txBody)) { | ||
TTxController::TProposeResult proposeResult(NKikimrTxColumnShard::EResultStatus::ERROR, TStringBuilder() << "Error processing commit TxId# " << txInfo.TxId | ||
<< (txOperator ? ". Parsing error " : ". Unknown operator for txKind")); | ||
OnProposeError(proposeResult, txInfo); | ||
return; | ||
} | ||
|
||
auto txInfoPtr = Self->GetProgressTxController().GetTxInfo(txInfo.TxId); | ||
if (!!txInfoPtr) { | ||
if (txInfoPtr->Source != source || txInfoPtr->Cookie != cookie) { | ||
TTxController::TProposeResult proposeResult(NKikimrTxColumnShard::EResultStatus::ERROR, TStringBuilder() << "Another commit TxId# " << txInfo.TxId << " has already been proposed"); | ||
OnProposeError(proposeResult, txInfo); | ||
} | ||
TTxController::TProposeResult proposeResult; | ||
OnProposeResult(proposeResult, *txInfoPtr); | ||
} else { | ||
auto proposeResult = txOperator->Propose(*Self, txc, false); | ||
if (!!proposeResult) { | ||
const auto fullTxInfo = txOperator->TxWithDeadline() ? Self->GetProgressTxController().RegisterTxWithDeadline(txInfo.TxId, txInfo.TxKind, txBody, source, cookie, txc) | ||
: Self->GetProgressTxController().RegisterTx(txInfo.TxId, txInfo.TxKind, txBody, source, cookie, txc); | ||
|
||
OnProposeResult(proposeResult, fullTxInfo); | ||
} else { | ||
OnProposeError(proposeResult, txInfo); | ||
} | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
ydb/core/tx/columnshard/transactions/propose_transaction_base.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#pragma once | ||
#include "tx_controller.h" | ||
|
||
namespace NKikimr::NColumnShard { | ||
|
||
class TColumnShard; | ||
|
||
class TProposeTransactionBase : public NTabletFlatExecutor::TTransactionBase<TColumnShard> { | ||
public: | ||
TProposeTransactionBase(TColumnShard* self) | ||
: TBase(self) | ||
{} | ||
|
||
protected: | ||
void ProposeTransaction(const TTxController::TBasicTxInfo& txInfo, const TString& txBody, const TActorId source, const ui64 cookie, TTransactionContext& txc); | ||
|
||
virtual void OnProposeResult(TTxController::TProposeResult& proposeResult, const TTxController::TTxInfo& txInfo) = 0; | ||
virtual void OnProposeError(TTxController::TProposeResult& proposeResult, const TTxController::TBasicTxInfo& txInfo) = 0; | ||
}; | ||
|
||
|
||
} |
Oops, something went wrong.