Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shnikd committed Oct 15, 2024
1 parent 8633106 commit bf388f1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion ydb/core/tx/schemeshard/schemeshard__init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3434,7 +3434,7 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> {
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);
Expand Down
38 changes: 19 additions & 19 deletions ydb/core/tx/schemeshard/schemeshard__operation_move_sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class TConfigureParts : public TSubOperationState {
class TPropose: public TSubOperationState {
private:
TOperationId OperationId;
TTxState::ETxState& NextState;

TString DebugHint() const override {
return TStringBuilder()
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -238,7 +237,7 @@ class TWaitRenamedPathPublication: public TSubOperationState {

TString DebugHint() const override {
return TStringBuilder()
<< "TMoveTableIndex TWaitRenamedPathPublication"
<< "TMoveSequence TWaitRenamedPathPublication"
<< " operationId: " << OperationId;
}

Expand Down Expand Up @@ -307,7 +306,7 @@ class TDeleteTableBarrier: public TSubOperationState {

TString DebugHint() const override {
return TStringBuilder()
<< "TMoveTableIndex TDeleteTableBarrier"
<< "TMoveSequence TDeleteTableBarrier"
<< " operationId: " << OperationId;
}

Expand Down Expand Up @@ -706,6 +705,7 @@ class TDone: public TSubOperationState {
};

class TMoveSequence: public TSubOperation {
TTxState::ETxState AfterPropose = TTxState::Invalid;

static TTxState::ETxState NextState() {
return TTxState::CreateParts;
Expand All @@ -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:
Expand All @@ -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<TWaitRenamedPathPublication>(OperationId);
case TTxState::DeletePathBarrier:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 7 additions & 4 deletions ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,21 @@ 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;
}

TPath dstIndexPath = dstPath.Child(name);
Y_ABORT_UNLESS(dstIndexPath.IsResolved());

auto remap = move->AddReMapIndexes();
PathIdFromPathId(srcIndexPath->PathId, remap->MutableSrcPathId());
PathIdFromPathId(srcChildPath->PathId, remap->MutableSrcPathId());
PathIdFromPathId(dstIndexPath->PathId, remap->MutableDstPathId());
}

Expand Down

0 comments on commit bf388f1

Please sign in to comment.