Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2c45118
WIP
Enjection Jun 2, 2025
1840aff
WIP
Enjection Jun 3, 2025
ab07950
WIP: test for restore control plane
Enjection Jun 13, 2025
2878475
WIP: improve tests
Enjection Jun 14, 2025
27bb60a
basic persist
Enjection Jun 14, 2025
79029f0
tidy tests
Enjection Jun 14, 2025
28d30e8
fixing tests
Enjection Jun 14, 2025
38ac8ca
fixing tests
Enjection Jun 14, 2025
c5c78b5
fixing tests
Enjection Jun 14, 2025
2c9ef1d
fixing tests
Enjection Jun 14, 2025
0b88e05
fixing path states
Enjection Jun 15, 2025
d7c86b0
add change path state op
Enjection Jun 15, 2025
17df393
add change path state op
Enjection Jun 15, 2025
ee40aae
fix
Enjection Jun 15, 2025
d4db8cf
better TChangePathStateOp
Enjection Jun 15, 2025
6f9794f
better TChangePathStateOp
Enjection Jun 15, 2025
898facf
better TChangePathStateOp
Enjection Jun 15, 2025
4128beb
better TChangePathStateOp
Enjection Jun 15, 2025
8e4621b
better TChangePathStateOp
Enjection Jun 15, 2025
d1fadfd
better TChangePathStateOp
Enjection Jun 15, 2025
7bc0db9
better TChangePathStateOp
Enjection Jun 15, 2025
c305383
fix immediate
Enjection Jun 15, 2025
4dc4310
temporary mute
Enjection Jun 16, 2025
4541ae9
simplify
Enjection Jun 16, 2025
7c57f15
fix issues
Enjection Jun 16, 2025
997062f
remove nonsense tests
Enjection Jun 16, 2025
cb77c56
small fixes
Enjection Jun 16, 2025
d2211e5
small fixes
Enjection Jun 16, 2025
14fbe5b
small fixes
Enjection Jun 16, 2025
f0cb8d9
small fixes
Enjection Jun 16, 2025
54b3683
merge similar
Enjection Jun 16, 2025
e1473c1
simplify
Enjection Jun 16, 2025
9faa953
simplify
Enjection Jun 16, 2025
15a8b4f
extract op
Enjection Jun 16, 2025
62201da
fix tests
Enjection Jun 16, 2025
0fb3085
fix
Enjection Jun 17, 2025
be20a7e
fix
Enjection Jun 17, 2025
40604b8
fix
Enjection Jun 17, 2025
ffe0c53
refactor
Enjection Jun 17, 2025
a0c5393
cleanup
Enjection Jun 17, 2025
be1c4c4
fix
Enjection Jun 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/config/muted_ya.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ ydb/core/transfer/ut/large TransferLarge.Transfer100KM_10P_RowTable_TopicAutoPar
ydb/core/transfer/ut/large TransferLarge.Transfer1KM_1KP_RowTable_TopicAutoPartitioning
ydb/core/tx/conveyor_composite/ut CompositeConveyorTests.TestUniformDistribution
ydb/core/tx/datashard/ut_incremental_backup IncrementalBackup.ComplexRestoreBackupCollection+WithIncremental
ydb/core/tx/datashard/ut_incremental_backup IncrementalBackup.E2EBackupCollection
ydb/core/tx/datashard/ut_incremental_backup IncrementalBackup.SimpleBackupBackupCollection+WithIncremental
ydb/core/tx/datashard/ut_incremental_backup IncrementalBackup.SimpleRestoreBackupCollection+WithIncremental
ydb/core/tx/schemeshard/ut_background_cleaning TSchemeshardBackgroundCleaningTest.SchemeshardBackgroundCleaningTestCreateCleanManyTables
ydb/core/tx/schemeshard/ut_index_build VectorIndexBuildTest.BaseCase
ydb/core/tx/schemeshard/ut_login_large TSchemeShardLoginLargeTest.RemoveLogin_Many
Expand Down Expand Up @@ -315,4 +318,4 @@ ydb/tests/stress/log/tests test_workload.py.TestYdbLogWorkload.test[column]
ydb/tests/stress/mixedpy test_mixed.py.TestYdbMixedWorkload.test[column]
ydb/tests/stress/reconfig_state_storage_workload/tests sole chunk chunk
ydb/tests/stress/reconfig_state_storage_workload/tests test_board_workload.py.TestReconfigStateStorageBoardWorkload.test_state_storage_board
ydb/tools/stress_tool/ut TDeviceTestTool.PDiskTestLogWrite
ydb/tools/stress_tool/ut TDeviceTestTool.PDiskTestLogWrite
6 changes: 6 additions & 0 deletions ydb/core/protos/counters_schemeshard.proto
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ enum ESimpleCounters {
COUNTER_SYS_VIEW_COUNT = 196 [(CounterOpts) = {Name: "SysViewCount"}];
COUNTER_IN_FLIGHT_OPS_TxCreateSysView = 197 [(CounterOpts) = {Name: "InFlightOps/CreateSysView"}];
COUNTER_IN_FLIGHT_OPS_TxDropSysView = 198 [(CounterOpts) = {Name: "InFlightOps/DropSysView"}];

COUNTER_IN_FLIGHT_OPS_TxCreateLongIncrementalRestoreOp = 199 [(CounterOpts) = {Name: "InFlightOps/CreateLongIncrementalRestoreOp"}];
COUNTER_IN_FLIGHT_OPS_TxChangePathState = 200 [(CounterOpts) = {Name: "InFlightOps/ChangePathState"}];
}

enum ECumulativeCounters {
Expand Down Expand Up @@ -404,6 +407,9 @@ enum ECumulativeCounters {

COUNTER_FINISHED_OPS_TxCreateSysView = 119 [(CounterOpts) = {Name: "FinishedOps/CreateSysView"}];
COUNTER_FINISHED_OPS_TxDropSysView = 120 [(CounterOpts) = {Name: "FinishedOps/DropSysView"}];

COUNTER_FINISHED_OPS_TxCreateLongIncrementalRestoreOp = 121 [(CounterOpts) = {Name: "FinishedOps/CreateLongIncrementalRestoreOp"}];
COUNTER_FINISHED_OPS_TxChangePathState = 122 [(CounterOpts) = {Name: "FinishedOps/ChangePathState"}];
}

enum EPercentileCounters {
Expand Down
16 changes: 16 additions & 0 deletions ydb/core/protos/flat_scheme_op.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,8 @@ message TModifyScheme {

optional TSysViewDescription CreateSysView = 81;

optional TChangePathState ChangePathState = 82;

// Some entries are grouped by semantics, so are out of order
}

Expand Down Expand Up @@ -2235,3 +2237,17 @@ message TSysViewDescription {
optional string Name = 1;
optional NKikimrSysView.ESysViewType Type = 2;
}

message TLongIncrementalRestoreOp {
optional uint64 TxId = 1;
optional NKikimrProto.TPathID BackupCollectionPathId = 2;
optional string Id = 3;
repeated string TablePathList = 4;
optional string FullBackupTrimmedName = 5;
repeated string IncrementalBackupTrimmedNames = 6;
}

message TChangePathState {
optional string Path = 1;
optional EPathState TargetState = 2;
}
6 changes: 6 additions & 0 deletions ydb/core/protos/schemeshard/operations.proto
Original file line number Diff line number Diff line change
Expand Up @@ -178,5 +178,11 @@ enum EOperationType {
ESchemeOpCreateSysView = 116;
ESchemeOpDropSysView = 117;

// Long Incremental Restore
ESchemeOpCreateLongIncrementalRestoreOp = 118;

// Change Path State
ESchemeOpChangePathState = 119;

// Some entries are grouped by semantics, so are out of order
}
9 changes: 9 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard__init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3597,6 +3597,15 @@ struct TSchemeShard::TTxInit : public TTransactionBase<TSchemeShard> {
txState.TargetPathTargetState = proto.GetTxCopyTableExtraData().GetTargetPathTargetState();
}
}
} else if (txState.TxType == TTxState::TxChangePathState) {
if (!extraData.empty()) {
NKikimrSchemeOp::TGenericTxInFlyExtraData proto;
bool deserializeRes = ParseFromStringNoSizeLimit(proto, extraData);
Y_ABORT_UNLESS(deserializeRes);
if (proto.GetTxCopyTableExtraData().HasTargetPathTargetState()) {
txState.TargetPathTargetState = proto.GetTxCopyTableExtraData().GetTargetPathTargetState();
}
}
}

Y_ABORT_UNLESS(txState.TxType != TTxState::TxInvalid);
Expand Down
13 changes: 13 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard__operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,13 @@ ISubOperation::TPtr TOperation::RestorePart(TTxState::ETxType txType, TTxState::
case TTxState::ETxType::TxDropSysView:
return CreateDropSysView(NextPartId(), txState);

// ChangePathState
case TTxState::ETxType::TxChangePathState:
return CreateChangePathState(NextPartId(), txState);

case TTxState::ETxType::TxCreateLongIncrementalRestoreOp:
return CreateLongIncrementalRestoreOpControlPlane(NextPartId(), txState);

case TTxState::ETxType::TxInvalid:
Y_UNREACHABLE();
}
Expand Down Expand Up @@ -1567,12 +1574,18 @@ TVector<ISubOperation::TPtr> TDefaultOperationFactory::MakeOperationParts(
return CreateBackupIncrementalBackupCollection(op.NextPartId(), tx, context);
case NKikimrSchemeOp::EOperationType::ESchemeOpRestoreBackupCollection:
return CreateRestoreBackupCollection(op.NextPartId(), tx, context);
case NKikimrSchemeOp::EOperationType::ESchemeOpCreateLongIncrementalRestoreOp:
return {CreateLongIncrementalRestoreOpControlPlane(op.NextPartId(), tx)};

// SysView
case NKikimrSchemeOp::EOperationType::ESchemeOpCreateSysView:
return {CreateNewSysView(op.NextPartId(), tx)};
case NKikimrSchemeOp::EOperationType::ESchemeOpDropSysView:
return {CreateDropSysView(op.NextPartId(), tx)};

// ChangePathState
case NKikimrSchemeOp::EOperationType::ESchemeOpChangePathState:
return CreateChangePathState(op.NextPartId(), tx, context);
}

Y_UNREACHABLE();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,13 @@ class TAlterCdcStream: public TSubOperation {
.NotDeleted()
.IsTable()
.NotAsyncReplicaTable()
.NotUnderOperation();
.NotUnderDeleting();

// Allow CDC operations on tables that are under incremental backup/restore
if (checks && tablePath.IsUnderOperation() &&
!tablePath.IsUnderOutgoingIncrementalRestore()) {
checks.NotUnderOperation();
}

if (checks && !tablePath.IsInsideTableIndexPath()) {
checks.IsCommonSensePath();
Expand Down Expand Up @@ -374,8 +380,13 @@ class TAlterCdcStreamAtTable: public TSubOperation {
.NotDeleted()
.IsTable()
.NotAsyncReplicaTable()
.NotUnderDeleting()
.NotUnderOperation();
.NotUnderDeleting();

// Allow CDC operations on tables that are under incremental backup/restore
if (checks && tablePath.IsUnderOperation() &&
!tablePath.IsUnderOutgoingIncrementalRestore()) {
checks.NotUnderOperation();
}

if (checks && !tablePath.IsInsideTableIndexPath()) {
checks.IsCommonSensePath();
Expand Down Expand Up @@ -498,8 +509,13 @@ std::variant<TStreamPaths, ISubOperation::TPtr> DoAlterStreamPathChecks(
.IsResolved()
.NotDeleted()
.IsTable()
.NotAsyncReplicaTable()
.NotUnderOperation();
.NotAsyncReplicaTable();

// Allow CDC operations on tables that are under incremental backup/restore
if (checks && tablePath.IsUnderOperation() &&
!tablePath.IsUnderOutgoingIncrementalRestore()) {
checks.NotUnderOperation();
}

if (checks && !tablePath.IsInsideTableIndexPath()) {
checks.IsCommonSensePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "schemeshard_impl.h"
#include "schemeshard__operation_common.h"
#include "schemeshard__operation_common_subdomain.h"
#include "schemeshard__operation_states.h"
#include "schemeshard_utils.h" // for TransactionTemplate

#include <ydb/core/base/subdomain.h>
Expand Down Expand Up @@ -561,33 +562,6 @@ class TCreateHive: public TSubOperationState {
}
};

class TEmptyPropose: public TSubOperationState {
private:
TOperationId OperationId;

TString DebugHint() const override {
return TStringBuilder() << "TEmptyPropose, operationId " << OperationId << ", ";
}

public:
TEmptyPropose(TOperationId id)
: OperationId(id)
{
IgnoreMessages(DebugHint(), {});
}

bool ProgressState(TOperationContext& context) override {
TTxState* txState = context.SS->FindTx(OperationId);
Y_ABORT_UNLESS(txState);

LOG_I(DebugHint() << "ProgressState, operation type " << TTxState::TypeName(txState->TxType));

context.OnComplete.ProposeToCoordinator(OperationId, txState->TargetPathId, TStepId(0));

return true;
}
};

class TAlterExtSubDomainCreateHive: public TSubOperation {
static TTxState::ETxState NextState() {
return TTxState::CreateParts;
Expand Down
63 changes: 63 additions & 0 deletions ydb/core/tx/schemeshard/schemeshard__operation_base.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#pragma once

#include "schemeshard__operation_part.h"
#include "schemeshard_impl.h"

namespace NKikimr::NSchemeShard {

/**
* Base class for sub-operations that need proper context-aware state management.
* This class provides common implementations for operations that:
* 1. Always use SetState with context for proper state transitions
* 2. Only use the context-aware SelectStateFunc overload
*
* Derived classes should override SelectStateFunc(TTxState::ETxState, TOperationContext&)
* instead of the non-context version.
*
* For operations that need custom NextState logic with context, they should override
* StateDone to call their custom NextState method.
*/
class TSubOperationWithContext : public TSubOperation {
protected:
using TSubOperation::SelectStateFunc;
using TSubOperation::NextState;
/**
* Properly handles state transitions by calling SetState with context
* and activating the transaction when moving to a valid next state.
*
* Derived classes can override this if they need custom StateDone logic.
*
* @param context The operation context containing database and completion handlers
*/
void StateDone(TOperationContext& context) override {
if (GetState() == TTxState::Done) {
return;
}

TTxState::ETxState nextState;
nextState = NextState(GetState());

SetState(nextState, context);

if (nextState != TTxState::Invalid) {
context.OnComplete.ActivateTx(OperationId);
}
}

/**
* Default implementation that prevents use of the non-context SelectStateFunc.
* Derived classes should override SelectStateFunc(TTxState::ETxState, TOperationContext&)
* instead of this method.
*
* @param state The transaction state (unused)
* @return Always aborts, forcing use of context-aware version
*/
TSubOperationState::TPtr SelectStateFunc(TTxState::ETxState) override {
Y_ABORT("Unreachable code: TSubOperationWithContext should only use context-aware SelectStateFunc");
}

public:
using TSubOperation::TSubOperation;
};

} // namespace NKikimr::NSchemeShard
Loading