@@ -333,6 +333,45 @@ class TCreateRestoreOpControlPlane: public TSubOperation {
333333 }
334334 }
335335
336+ TSubOperationState::TPtr SelectStateFunc (TTxState::ETxState state, TOperationContext& context) override {
337+ switch (state) {
338+ case TTxState::Waiting:
339+ case TTxState::Propose:
340+ return MakeHolder<TEmptyPropose>(OperationId);
341+ case TTxState::CopyTableBarrier:
342+ return MakeHolder<TWaitCopyTableBarrier>(OperationId);
343+ case TTxState::Done: {
344+ // Get target state from transaction and create TDone with it
345+ // This will cause TDone::Process to apply the path state change
346+ const auto * txState = context.SS ->FindTx (OperationId);
347+ if (txState && txState->TargetPathTargetState .Defined ()) {
348+ auto targetState = static_cast <TPathElement::EPathState>(*txState->TargetPathTargetState );
349+ return MakeHolder<TDone>(OperationId, targetState);
350+ }
351+ return MakeHolder<TDone>(OperationId);
352+ }
353+ default :
354+ return nullptr ;
355+ }
356+ }
357+
358+ void StateDone (TOperationContext& context) override {
359+ // When we reach Done state, don't try to advance to Invalid state
360+ // Just complete the operation
361+ if (GetState () == TTxState::Done) {
362+ // Operation is complete, no need to advance state
363+ return ;
364+ }
365+
366+ // For other states, use normal state advancement
367+ auto nextState = NextState (GetState ());
368+ SetState (nextState, context);
369+
370+ if (nextState != TTxState::Invalid) {
371+ context.OnComplete .ActivateTx (OperationId);
372+ }
373+ }
374+
336375public:
337376 using TSubOperation::TSubOperation;
338377
@@ -355,6 +394,9 @@ class TCreateRestoreOpControlPlane: public TSubOperation {
355394
356395 // Set the target path ID for coordinator communication
357396 txState.TargetPathId = bcPath.Base ()->PathId ;
397+
398+ // Set the target state for the backup collection path to outgoing incremental restore
399+ txState.TargetPathTargetState = NKikimrSchemeOp::EPathStateOutgoingIncrementalRestore;
358400
359401 auto result = MakeHolder<TProposeResponse>(NKikimrScheme::StatusAccepted, ui64 (OperationId.GetTxId ()), ui64 (schemeshardTabletId));
360402
@@ -416,7 +458,7 @@ class TCreateRestoreOpControlPlane: public TSubOperation {
416458 context.DbChanges .PersistLongIncrementalRestoreOp (op);
417459
418460 // Set initial operation state
419- SetState (NextState ());
461+ SetState (NextState (), context );
420462
421463 return result;
422464 }
0 commit comments