From f6f60c929995112eae9d5797eb086ed6976e999b Mon Sep 17 00:00:00 2001 From: Evgeny Zverev Date: Sat, 4 Jan 2025 11:42:12 +0000 Subject: [PATCH] Remove unnecessary template from TExtendedTransactionBase --- .../transaction/tx_blobs_written.h | 8 +++--- .../blobs_action/transaction/tx_write.h | 4 +-- .../transactions/tx_data_from_source.h | 4 +-- .../tx_finish_ack_from_initiator.h | 4 +-- .../transactions/tx_finish_from_source.h | 4 +-- .../transactions/tx_start_from_initiator.h | 8 +++--- .../transactions/tx_change_blobs_owning.h | 4 +-- .../transactions/tx_data_ack_to_source.h | 4 +-- .../transactions/tx_finish_ack_to_source.h | 4 +-- .../transactions/tx_start_source_cursor.h | 4 +-- .../source/transactions/tx_start_to_source.h | 4 +-- .../transactions/tx_write_source_cursor.h | 4 +-- .../tx/columnshard/tablet/ext_tx_base.cpp | 25 ++++++++++++++++--- ydb/core/tx/columnshard/tablet/ext_tx_base.h | 25 ++++++------------- ydb/core/tx/columnshard/tablet/ya.make | 2 +- .../transactions/operators/ev_write/primary.h | 12 ++++----- .../operators/ev_write/secondary.h | 12 ++++----- 17 files changed, 70 insertions(+), 62 deletions(-) diff --git a/ydb/core/tx/columnshard/blobs_action/transaction/tx_blobs_written.h b/ydb/core/tx/columnshard/blobs_action/transaction/tx_blobs_written.h index 9284b3aa1bd0..db432b25e152 100644 --- a/ydb/core/tx/columnshard/blobs_action/transaction/tx_blobs_written.h +++ b/ydb/core/tx/columnshard/blobs_action/transaction/tx_blobs_written.h @@ -12,9 +12,9 @@ namespace NKikimr::NColumnShard { class TColumnShard; -class TTxBlobsWritingFinished: public TExtendedTransactionBase { +class TTxBlobsWritingFinished: public TExtendedTransactionBase { private: - using TBase = TExtendedTransactionBase; + using TBase = TExtendedTransactionBase; std::vector Packs; const std::shared_ptr WritingActions; std::optional CommitSnapshot; @@ -51,9 +51,9 @@ class TTxBlobsWritingFinished: public TExtendedTransactionBase { } }; -class TTxBlobsWritingFailed: public TExtendedTransactionBase { +class TTxBlobsWritingFailed: public TExtendedTransactionBase { private: - using TBase = TExtendedTransactionBase; + using TBase = TExtendedTransactionBase; const NKikimrProto::EReplyStatus PutBlobResult; std::vector Packs; diff --git a/ydb/core/tx/columnshard/blobs_action/transaction/tx_write.h b/ydb/core/tx/columnshard/blobs_action/transaction/tx_write.h index c93b26c0d3de..6482947d0095 100644 --- a/ydb/core/tx/columnshard/blobs_action/transaction/tx_write.h +++ b/ydb/core/tx/columnshard/blobs_action/transaction/tx_write.h @@ -5,9 +5,9 @@ namespace NKikimr::NColumnShard { -class TTxWrite: public TExtendedTransactionBase { +class TTxWrite: public TExtendedTransactionBase { private: - using TBase = TExtendedTransactionBase; + using TBase = TExtendedTransactionBase; public: TTxWrite(TColumnShard* self, const TEvPrivate::TEvWriteBlobsResult::TPtr& putBlobResult) diff --git a/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_data_from_source.h b/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_data_from_source.h index 6bc90df7f5dd..a709ec9e0e57 100644 --- a/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_data_from_source.h +++ b/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_data_from_source.h @@ -9,9 +9,9 @@ namespace NKikimr::NOlap::NDataSharing { -class TTxDataFromSource: public NColumnShard::TExtendedTransactionBase { +class TTxDataFromSource: public NColumnShard::TExtendedTransactionBase { private: - using TBase = NColumnShard::TExtendedTransactionBase; + using TBase = NColumnShard::TExtendedTransactionBase; std::shared_ptr Session; THashMap PortionsByPathId; THashMap> SharedBlobIds; diff --git a/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_finish_ack_from_initiator.h b/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_finish_ack_from_initiator.h index 84a833e5afc8..d9374f39c158 100644 --- a/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_finish_ack_from_initiator.h +++ b/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_finish_ack_from_initiator.h @@ -5,9 +5,9 @@ namespace NKikimr::NOlap::NDataSharing { -class TTxFinishAckFromInitiator: public NColumnShard::TExtendedTransactionBase { +class TTxFinishAckFromInitiator: public NColumnShard::TExtendedTransactionBase { private: - using TBase = NColumnShard::TExtendedTransactionBase; + using TBase = NColumnShard::TExtendedTransactionBase; std::shared_ptr Session; protected: virtual bool DoExecute(NTabletFlatExecutor::TTransactionContext& txc, const TActorContext& ctx) override; diff --git a/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_finish_from_source.h b/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_finish_from_source.h index 3f4ef3894ff5..65f8ad992c41 100644 --- a/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_finish_from_source.h +++ b/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_finish_from_source.h @@ -5,9 +5,9 @@ namespace NKikimr::NOlap::NDataSharing { -class TTxFinishFromSource: public NColumnShard::TExtendedTransactionBase { +class TTxFinishFromSource: public NColumnShard::TExtendedTransactionBase { private: - using TBase = NColumnShard::TExtendedTransactionBase; + using TBase = NColumnShard::TExtendedTransactionBase; std::shared_ptr Session; const TTabletId SourceTabletId; bool Finished = false; diff --git a/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_start_from_initiator.h b/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_start_from_initiator.h index ed6d7cda3e68..c3e196dc2a28 100644 --- a/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_start_from_initiator.h +++ b/ydb/core/tx/columnshard/data_sharing/destination/transactions/tx_start_from_initiator.h @@ -5,9 +5,9 @@ namespace NKikimr::NOlap::NDataSharing { -class TTxProposeFromInitiator: public NColumnShard::TExtendedTransactionBase { +class TTxProposeFromInitiator: public NColumnShard::TExtendedTransactionBase { private: - using TBase = NColumnShard::TExtendedTransactionBase; + using TBase = NColumnShard::TExtendedTransactionBase; std::shared_ptr Session; THashMap>* Sessions; protected: @@ -23,9 +23,9 @@ class TTxProposeFromInitiator: public NColumnShard::TExtendedTransactionBase { +class TTxConfirmFromInitiator: public NColumnShard::TExtendedTransactionBase { private: - using TBase = NColumnShard::TExtendedTransactionBase; + using TBase = NColumnShard::TExtendedTransactionBase; std::shared_ptr Session; protected: virtual bool DoExecute(NTabletFlatExecutor::TTransactionContext& txc, const TActorContext& ctx) override; diff --git a/ydb/core/tx/columnshard/data_sharing/modification/transactions/tx_change_blobs_owning.h b/ydb/core/tx/columnshard/data_sharing/modification/transactions/tx_change_blobs_owning.h index 77cd10ec35a7..acff824ce70c 100644 --- a/ydb/core/tx/columnshard/data_sharing/modification/transactions/tx_change_blobs_owning.h +++ b/ydb/core/tx/columnshard/data_sharing/modification/transactions/tx_change_blobs_owning.h @@ -7,9 +7,9 @@ namespace NKikimr::NOlap::NDataSharing { class TTaskForTablet; -class TTxApplyLinksModification: public NColumnShard::TExtendedTransactionBase { +class TTxApplyLinksModification: public NColumnShard::TExtendedTransactionBase { private: - using TBase = NColumnShard::TExtendedTransactionBase; + using TBase = NColumnShard::TExtendedTransactionBase; std::shared_ptr Task; const TTabletId InitiatorTabletId; const TString SessionId; diff --git a/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_data_ack_to_source.h b/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_data_ack_to_source.h index 0c5a99bbcbce..14af9304b0d9 100644 --- a/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_data_ack_to_source.h +++ b/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_data_ack_to_source.h @@ -6,9 +6,9 @@ namespace NKikimr::NOlap::NDataSharing { -class TTxDataAckToSource: public NColumnShard::TExtendedTransactionBase { +class TTxDataAckToSource: public NColumnShard::TExtendedTransactionBase { private: - using TBase = NColumnShard::TExtendedTransactionBase; + using TBase = NColumnShard::TExtendedTransactionBase; std::shared_ptr Session; THashMap SharedBlobIds; protected: diff --git a/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_finish_ack_to_source.h b/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_finish_ack_to_source.h index d63e5ef0abad..3a9488aaf177 100644 --- a/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_finish_ack_to_source.h +++ b/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_finish_ack_to_source.h @@ -5,9 +5,9 @@ namespace NKikimr::NOlap::NDataSharing { -class TTxFinishAckToSource: public NColumnShard::TExtendedTransactionBase { +class TTxFinishAckToSource: public NColumnShard::TExtendedTransactionBase { private: - using TBase = NColumnShard::TExtendedTransactionBase; + using TBase = NColumnShard::TExtendedTransactionBase; std::shared_ptr Session; protected: virtual bool DoExecute(NTabletFlatExecutor::TTransactionContext& txc, const TActorContext& ctx) override; diff --git a/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_start_source_cursor.h b/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_start_source_cursor.h index d75cd64d3fc8..7fa82682daad 100644 --- a/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_start_source_cursor.h +++ b/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_start_source_cursor.h @@ -5,9 +5,9 @@ namespace NKikimr::NOlap::NDataSharing { -class TTxStartSourceCursor: public NColumnShard::TExtendedTransactionBase { +class TTxStartSourceCursor: public NColumnShard::TExtendedTransactionBase { private: - using TBase = NColumnShard::TExtendedTransactionBase; + using TBase = NColumnShard::TExtendedTransactionBase; TSourceSession* Session; THashMap> Portions; diff --git a/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_start_to_source.h b/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_start_to_source.h index ed4cf37b3676..5c787281f47b 100644 --- a/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_start_to_source.h +++ b/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_start_to_source.h @@ -5,9 +5,9 @@ namespace NKikimr::NOlap::NDataSharing { -class TTxStartToSource: public NColumnShard::TExtendedTransactionBase { +class TTxStartToSource: public NColumnShard::TExtendedTransactionBase { private: - using TBase = NColumnShard::TExtendedTransactionBase; + using TBase = NColumnShard::TExtendedTransactionBase; std::shared_ptr Session; THashMap>* Sessions; protected: diff --git a/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_write_source_cursor.h b/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_write_source_cursor.h index 1bc6a50b2c1c..e87f809a2f2e 100644 --- a/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_write_source_cursor.h +++ b/ydb/core/tx/columnshard/data_sharing/source/transactions/tx_write_source_cursor.h @@ -6,9 +6,9 @@ namespace NKikimr::NOlap::NDataSharing { -class TTxWriteSourceCursor: public NColumnShard::TExtendedTransactionBase { +class TTxWriteSourceCursor: public NColumnShard::TExtendedTransactionBase { private: - using TBase = NColumnShard::TExtendedTransactionBase; + using TBase = NColumnShard::TExtendedTransactionBase; std::shared_ptr Session; protected: virtual bool DoExecute(NTabletFlatExecutor::TTransactionContext& txc, const TActorContext& ctx) override; diff --git a/ydb/core/tx/columnshard/tablet/ext_tx_base.cpp b/ydb/core/tx/columnshard/tablet/ext_tx_base.cpp index 8a97c55b0ed3..f5a852ac8c36 100644 --- a/ydb/core/tx/columnshard/tablet/ext_tx_base.cpp +++ b/ydb/core/tx/columnshard/tablet/ext_tx_base.cpp @@ -1,5 +1,24 @@ -#include "tx_extension.h" +#include "ext_tx_base.h" +#include -namespace NKikimr::NColumnShard::NDataSharing { -} \ No newline at end of file +namespace NKikimr::NColumnShard { + +bool TExtendedTransactionBase::Execute(NTabletFlatExecutor::TTransactionContext& txc, const NActors::TActorContext& ctx) { + NActors::TLogContextGuard logGuard = NActors::TLogContextBuilder::Build()("tablet_id", Self->TabletID())("local_tx_no", TabletTxNo)("method", "execute")("tx_info", TxInfo); + return DoExecute(txc, ctx); +} +void TExtendedTransactionBase::Complete(const NActors::TActorContext& ctx) { + NActors::TLogContextGuard logGuard = NActors::TLogContextBuilder::Build()("tablet_id", Self->TabletID())("local_tx_no", TabletTxNo)("method", "complete")("tx_info", TxInfo); + DoComplete(ctx); +} + +TExtendedTransactionBase::TExtendedTransactionBase(TColumnShard* self, const TString& txInfo) + : TBase(self) + , TxInfo(txInfo) + , TabletTxNo(++Self->TabletTxCounter) +{ + +} + +} //namespace NKikimr::NColumnShard \ No newline at end of file diff --git a/ydb/core/tx/columnshard/tablet/ext_tx_base.h b/ydb/core/tx/columnshard/tablet/ext_tx_base.h index 0ce09cd536d0..ccfa4ef7e3af 100644 --- a/ydb/core/tx/columnshard/tablet/ext_tx_base.h +++ b/ydb/core/tx/columnshard/tablet/ext_tx_base.h @@ -4,33 +4,22 @@ namespace NKikimr::NColumnShard { +class TColumnShard; + //Base class for LocalDB transactions with ColumnShard specific -template -class TExtendedTransactionBase: public NTabletFlatExecutor::TTransactionBase { +class TExtendedTransactionBase: public NTabletFlatExecutor::TTransactionBase { private: const TString TxInfo; const ui32 TabletTxNo; - using TBase = NTabletFlatExecutor::TTransactionBase; + using TBase = NTabletFlatExecutor::TTransactionBase; virtual bool DoExecute(NTabletFlatExecutor::TTransactionContext& txc, const NActors::TActorContext& ctx) = 0; virtual void DoComplete(const NActors::TActorContext & ctx) = 0; public: - virtual bool Execute(NTabletFlatExecutor::TTransactionContext& txc, const NActors::TActorContext& ctx) override final { - NActors::TLogContextGuard logGuard = NActors::TLogContextBuilder::Build()("tablet_id", TBase::Self->TabletID())("local_tx_no", TabletTxNo)("tx_info", TxInfo); - return DoExecute(txc, ctx); - } - virtual void Complete(const NActors::TActorContext& ctx) override final { - NActors::TLogContextGuard logGuard = NActors::TLogContextBuilder::Build()("tablet_id", TBase::Self->TabletID())("local_tx_no", TabletTxNo)("tx_info", TxInfo); - return DoComplete(ctx); - } - - TExtendedTransactionBase(TShard* self, const TString& txInfo = Default()) - : TBase(self) - , TxInfo(txInfo) - , TabletTxNo(++TBase::Self->TabletTxCounter) - { + virtual bool Execute(NTabletFlatExecutor::TTransactionContext& txc, const NActors::TActorContext& ctx) override final; + virtual void Complete(const NActors::TActorContext& ctx) override final; - } + TExtendedTransactionBase(TColumnShard* self, const TString& txInfo = Default()); }; } //namespace NKikimr::NColumnShard diff --git a/ydb/core/tx/columnshard/tablet/ya.make b/ydb/core/tx/columnshard/tablet/ya.make index 22c4eb05424a..c7953e768a86 100644 --- a/ydb/core/tx/columnshard/tablet/ya.make +++ b/ydb/core/tx/columnshard/tablet/ya.make @@ -1,7 +1,7 @@ LIBRARY() SRCS( - ext_tx_base.h + ext_tx_base.cpp write_queue.cpp ) diff --git a/ydb/core/tx/columnshard/transactions/operators/ev_write/primary.h b/ydb/core/tx/columnshard/transactions/operators/ev_write/primary.h index b8b6fd85a5b1..0a8137fd9d31 100644 --- a/ydb/core/tx/columnshard/transactions/operators/ev_write/primary.h +++ b/ydb/core/tx/columnshard/transactions/operators/ev_write/primary.h @@ -77,9 +77,9 @@ class TEvWriteCommitPrimaryTransactionOperator: public TEvWriteCommitSyncTransac virtual TString DoDebugString() const override { return "EV_WRITE_PRIMARY"; } - class TTxWriteReceivedBrokenFlag: public TExtendedTransactionBase { + class TTxWriteReceivedBrokenFlag: public TExtendedTransactionBase { private: - using TBase = TExtendedTransactionBase; + using TBase = TExtendedTransactionBase; const ui64 TxId; const ui64 TabletId; const bool BrokenFlag; @@ -126,9 +126,9 @@ class TEvWriteCommitPrimaryTransactionOperator: public TEvWriteCommitSyncTransac return std::make_unique(owner, GetTxId(), sendTabletId, broken); } - class TTxWriteReceivedResultAck: public TExtendedTransactionBase { + class TTxWriteReceivedResultAck: public TExtendedTransactionBase { private: - using TBase = TExtendedTransactionBase; + using TBase = TExtendedTransactionBase; const ui64 TxId; const ui64 TabletId; @@ -222,9 +222,9 @@ class TEvWriteCommitPrimaryTransactionOperator: public TEvWriteCommitSyncTransac CheckFinished(owner); } - class TTxStartPreparation: public TExtendedTransactionBase { + class TTxStartPreparation: public TExtendedTransactionBase { private: - using TBase = TExtendedTransactionBase; + using TBase = TExtendedTransactionBase; const ui64 TxId; virtual bool DoExecute(NTabletFlatExecutor::TTransactionContext& txc, const NActors::TActorContext& /*ctx*/) override { diff --git a/ydb/core/tx/columnshard/transactions/operators/ev_write/secondary.h b/ydb/core/tx/columnshard/transactions/operators/ev_write/secondary.h index e6f0ab4fa3c2..9c271d3f89e9 100644 --- a/ydb/core/tx/columnshard/transactions/operators/ev_write/secondary.h +++ b/ydb/core/tx/columnshard/transactions/operators/ev_write/secondary.h @@ -58,9 +58,9 @@ class TEvWriteCommitSecondaryTransactionOperator: public TEvWriteCommitSyncTrans virtual TString DoDebugString() const override { return "EV_WRITE_SECONDARY"; } - class TTxWriteReceivedAck: public TExtendedTransactionBase { + class TTxWriteReceivedAck: public TExtendedTransactionBase { private: - using TBase = TExtendedTransactionBase; + using TBase = TExtendedTransactionBase; const ui64 TxId; bool NeedContinueFlag = false; @@ -99,9 +99,9 @@ class TEvWriteCommitSecondaryTransactionOperator: public TEvWriteCommitSyncTrans return std::make_unique(owner, GetTxId()); } - class TTxWriteReceivedBrokenFlag: public TExtendedTransactionBase { + class TTxWriteReceivedBrokenFlag: public TExtendedTransactionBase { private: - using TBase = TExtendedTransactionBase; + using TBase = TExtendedTransactionBase; const ui64 TxId; const bool BrokenFlag; @@ -170,9 +170,9 @@ class TEvWriteCommitSecondaryTransactionOperator: public TEvWriteCommitSyncTrans } } - class TTxStartPreparation: public TExtendedTransactionBase { + class TTxStartPreparation: public TExtendedTransactionBase { private: - using TBase = TExtendedTransactionBase; + using TBase = TExtendedTransactionBase; const ui64 TxId; virtual bool DoExecute(NTabletFlatExecutor::TTransactionContext& txc, const NActors::TActorContext& /*ctx*/) override {