diff options
author | ijon <ijon@yandex-team.com> | 2023-03-28 17:55:59 +0300 |
---|---|---|
committer | ijon <ijon@yandex-team.com> | 2023-03-28 17:55:59 +0300 |
commit | 43fe77306a31d3406f558a7ead496b1b2ef4d09c (patch) | |
tree | 11af3aee827f8a9ee945a108837d0b2665737b0a | |
parent | 0923168860cdb7f68aa9486e5a3714f5f0c7bf97 (diff) | |
download | ydb-43fe77306a31d3406f558a7ead496b1b2ef4d09c.tar.gz |
schemeshard: simplify TTxOperationReply<>::Execute
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard__operation.cpp | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation.cpp b/ydb/core/tx/schemeshard/schemeshard__operation.cpp index ac5dfee785..feb63f6e6e 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation.cpp @@ -373,7 +373,7 @@ template <> void OutOfScopeEventHandler<TEvDataShard::TEvSchemaChanged>(const TEvDataShard::TEvSchemaChanged::TPtr& ev, TOperationContext& context) { const auto txId = ev->Get()->Record.GetTxId(); LOG_DEBUG_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, - "TTxOperationReply<TEvDataShard::TEvSchemaChanged> execute" + "TTxOperationReply<" << ev->GetTypeName() << "> execute" << ", at schemeshard: " << context.SS->TabletID() << ", send out-of-scope reply, for txId " << txId ); @@ -419,38 +419,45 @@ struct TTxOperationReply : public NTabletFlatExecutor::TTransactionBase<TSchemeS } bool Execute(NTabletFlatExecutor::TTransactionContext& txc, const TActorContext& ctx) override { - LOG_DEBUG_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, - "TTxOperationReply<" << EvReply->GetTypeName() << "> execute" - << ", operationId: " << OperationId - << ", at schemeshard: " << Self->TabletID() - << ", message: " << ISubOperationState::DebugReply(EvReply)); - if (!Self->Operations.contains(OperationId.GetTxId())) { - LOG_DEBUG_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, - "TTxOperationReply<" << EvReply->GetTypeName() << "> execute " - << ", operationId: " << OperationId - << ", at schemeshard: " << Self->TabletID() - << ", operation unknown"); - TOperationContext context{Self, txc, ctx, OnComplete, MemChanges, DbChanges}; - OutOfScopeEventHandler<TEvType>(EvReply, context); - return true; - } - TOperation::TPtr operation = Self->Operations.at(OperationId.GetTxId()); - if (operation->DoneParts.contains(OperationId.GetSubTxId())) { - LOG_DEBUG_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, - "TTxOperationReply<" << EvReply->GetTypeName() << "> execute" - << ", operationId: " << OperationId - << ", at schemeshard: " << Self->TabletID() - << ", operation part is already done"); + + auto findActiveSubOperation = [this](const TOperationId& operationId) -> ISubOperation::TPtr { + if (auto found = Self->Operations.find(operationId.GetTxId()); found != Self->Operations.cend()) { + const auto operation = found->second; + const auto subOperationId = operationId.GetSubTxId(); + if (!operation->DoneParts.contains(subOperationId)) { + return operation->Parts.at(subOperationId); + } + } + return nullptr; + }; + + ISubOperation::TPtr part = findActiveSubOperation(OperationId); + + LOG_DEBUG_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "TTxOperationReply<" << EvReply->GetTypeName() << "> execute" + << ", operationId: " << OperationId + << ", at schemeshard: " << Self->TabletID() + << ", message: " << ISubOperationState::DebugReply(EvReply) + ); + + { TOperationContext context{Self, txc, ctx, OnComplete, MemChanges, DbChanges}; - OutOfScopeEventHandler<TEvType>(EvReply, context); - return true; + + if (part) { + part->HandleReply(EvReply, context); + + } else { + LOG_WARN_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, "TTxOperationReply<" << EvReply->GetTypeName() << "> execute" + << ", operationId: " << OperationId + << ", at schemeshard: " << Self->TabletID() + << ", unknown operation or suboperation is already done, event is out-of-scope" + ); + + OutOfScopeEventHandler<TEvType>(EvReply, context); + } } - ISubOperation::TPtr part = operation->Parts.at(ui64(OperationId.GetSubTxId())); - TOperationContext context{Self, txc, ctx, OnComplete, MemChanges, DbChanges}; - Y_VERIFY(EvReply); - part->HandleReply(EvReply, context); OnComplete.ApplyOnExecute(Self, txc, ctx); DbChanges.Apply(Self, txc, ctx); + return true; } |