From bf388f1d47799f205e5ef205329a9ddf64441dca Mon Sep 17 00:00:00 2001 From: Nikolay Shumkov Date: Tue, 15 Oct 2024 05:06:46 +0300 Subject: [PATCH] Fixes --- ydb/core/tx/schemeshard/schemeshard__init.cpp | 2 +- .../schemeshard__operation_move_sequence.cpp | 38 +++++++++---------- .../schemeshard__operation_move_table.cpp | 11 ++++-- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/ydb/core/tx/schemeshard/schemeshard__init.cpp b/ydb/core/tx/schemeshard/schemeshard__init.cpp index aae82d37ac8c..b3f2dee95bfd 100644 --- a/ydb/core/tx/schemeshard/schemeshard__init.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__init.cpp @@ -3434,7 +3434,7 @@ struct TSchemeShard::TTxInit : public TTransactionBase { srcPath->DbRefCount++; } - if (txState.TxType == TTxState::TxMoveTable || txState.TxType == TTxState::TxMoveTableIndex) { + if (txState.TxType == TTxState::TxMoveTable || txState.TxType == TTxState::TxMoveTableIndex || txState.TxType == TTxState::TxMoveSequence) { Y_ABORT_UNLESS(txState.SourcePathId); TPathElement::TPtr srcPath = Self->PathsById.at(txState.SourcePathId); Y_VERIFY_S(srcPath, "Null path element, pathId: " << txState.SourcePathId); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_move_sequence.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_move_sequence.cpp index e20a302546d8..f613ef4cfdff 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_move_sequence.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_move_sequence.cpp @@ -148,6 +148,7 @@ class TConfigureParts : public TSubOperationState { class TPropose: public TSubOperationState { private: TOperationId OperationId; + TTxState::ETxState& NextState; TString DebugHint() const override { return TStringBuilder() @@ -156,8 +157,9 @@ class TPropose: public TSubOperationState { } public: - TPropose(TOperationId id) + TPropose(TOperationId id, TTxState::ETxState& nextState) : OperationId(id) + , NextState(nextState) { IgnoreMessages(DebugHint(), { TEvHive::TEvCreateTabletReply::EventType, NSequenceShard::TEvSequenceShard::TEvCreateSequenceResult::EventType @@ -178,8 +180,10 @@ class TPropose: public TSubOperationState { } Y_ABORT_UNLESS(txState->TxType == TTxState::TxMoveSequence); + auto srcPath = TPath::Init(txState->SourcePathId, context.SS); + auto dstPath = TPath::Init(txState->TargetPathId, context.SS); + TPathId pathId = txState->TargetPathId; - TPathElement::TPtr path = context.SS->PathsById.at(pathId); Y_VERIFY_S(context.SS->Sequences.contains(pathId), "Sequence not found. PathId: " << pathId); TSequenceInfo::TPtr sequenceInfo = context.SS->Sequences.at(pathId); @@ -196,20 +200,15 @@ class TPropose: public TSubOperationState { context.SS->PersistSequenceAlterRemove(db, pathId); context.SS->PersistSequence(db, pathId, *alterData); - auto parentDir = context.SS->PathsById.at(path->ParentPathId); - if (parentDir->IsLikeDirectory()) { - ++parentDir->DirAlterVersion; - context.SS->PersistPathDirAlterVersion(db, parentDir); - } - context.SS->ClearDescribePathCaches(parentDir); - context.OnComplete.PublishToSchemeBoard(OperationId, parentDir->PathId); + dstPath->StepCreated = step; + context.SS->PersistCreateStep(db, pathId, step); - context.SS->ClearDescribePathCaches(path); - context.OnComplete.PublishToSchemeBoard(OperationId, pathId); + dstPath.DomainInfo()->IncPathsInside(); - path->StepCreated = step; - context.SS->PersistCreateStep(db, path->PathId, step); + dstPath.Activate(); + IncParentDirAlterVersionWithRepublish(OperationId, dstPath, context); + NextState = TTxState::WaitShadowPathPublication; context.SS->ChangeTxState(db, OperationId, TTxState::WaitShadowPathPublication); return true; } @@ -238,7 +237,7 @@ class TWaitRenamedPathPublication: public TSubOperationState { TString DebugHint() const override { return TStringBuilder() - << "TMoveTableIndex TWaitRenamedPathPublication" + << "TMoveSequence TWaitRenamedPathPublication" << " operationId: " << OperationId; } @@ -307,7 +306,7 @@ class TDeleteTableBarrier: public TSubOperationState { TString DebugHint() const override { return TStringBuilder() - << "TMoveTableIndex TDeleteTableBarrier" + << "TMoveSequence TDeleteTableBarrier" << " operationId: " << OperationId; } @@ -706,6 +705,7 @@ class TDone: public TSubOperationState { }; class TMoveSequence: public TSubOperation { + TTxState::ETxState AfterPropose = TTxState::Invalid; static TTxState::ETxState NextState() { return TTxState::CreateParts; @@ -719,7 +719,7 @@ class TMoveSequence: public TSubOperation { case TTxState::ConfigureParts: return TTxState::Propose; case TTxState::Propose: - return TTxState::WaitShadowPathPublication; + return AfterPropose; case TTxState::WaitShadowPathPublication: return TTxState::DeletePathBarrier; case TTxState::DeletePathBarrier: @@ -743,7 +743,7 @@ class TMoveSequence: public TSubOperation { case TTxState::ConfigureParts: return TPtr(new TConfigureParts(OperationId)); case TTxState::Propose: - return TPtr(new TPropose(OperationId)); + return TPtr(new TPropose(OperationId, AfterPropose)); case TTxState::WaitShadowPathPublication: return MakeHolder(OperationId); case TTxState::DeletePathBarrier: @@ -772,7 +772,7 @@ class TMoveSequence: public TSubOperation { const TString& dstPathStr = moveSequence.GetDstPath(); LOG_NOTICE_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD, - "TMoveTableIndex Propose" + "TMoveSequence Propose" << ", from: "<< srcPathStr << ", to: " << dstPathStr << ", opId: " << OperationId @@ -952,7 +952,7 @@ class TMoveSequence: public TSubOperation { TTxState& txState = context.SS->CreateTx(OperationId, TTxState::TxMoveSequence, dstPath.Base()->PathId, srcPath.Base()->PathId); - txState.State = TTxState::Propose; + txState.State = TTxState::CreateParts; Y_ABORT_UNLESS(context.SS->Sequences.contains(srcPath.Base()->PathId)); TSequenceInfo::TPtr srcSequence = context.SS->Sequences.at(srcPath.Base()->PathId); diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp index 297496dc8906..040d90e58fbc 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp @@ -98,10 +98,13 @@ class TConfigureParts: public TSubOperationState { for (const auto& child: srcPath->GetChildren()) { auto name = child.first; - TPath srcIndexPath = srcPath.Child(name); - Y_ABORT_UNLESS(srcIndexPath.IsResolved()); + TPath srcChildPath = srcPath.Child(name); + Y_ABORT_UNLESS(srcChildPath.IsResolved()); - if (srcIndexPath.IsDeleted()) { + if (srcChildPath.IsDeleted()) { + continue; + } + if (srcChildPath.IsSequence()) { continue; } @@ -109,7 +112,7 @@ class TConfigureParts: public TSubOperationState { Y_ABORT_UNLESS(dstIndexPath.IsResolved()); auto remap = move->AddReMapIndexes(); - PathIdFromPathId(srcIndexPath->PathId, remap->MutableSrcPathId()); + PathIdFromPathId(srcChildPath->PathId, remap->MutableSrcPathId()); PathIdFromPathId(dstIndexPath->PathId, remap->MutableDstPathId()); }