Skip to content

Commit cb655a4

Browse files
authored
Forbid scheme ops on backup table (#9431)
1 parent b2dd1e8 commit cb655a4

File tree

5 files changed

+47
-7
lines changed

5 files changed

+47
-7
lines changed

ydb/core/tx/schemeshard/schemeshard__operation_alter_table.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,10 @@ class TAlterTable: public TSubOperation {
524524
.IsTable()
525525
.NotUnderOperation();
526526

527-
if (!Transaction.GetInternal()) {
528-
checks.NotAsyncReplicaTable();
527+
if (checks && !Transaction.GetInternal()) {
528+
checks
529+
.NotAsyncReplicaTable()
530+
.NotBackupTable();
529531
}
530532

531533
if (!context.IsAllowedPrivateTables) {
@@ -727,6 +729,10 @@ TVector<ISubOperation::TPtr> CreateConsistentAlterTable(TOperationId id, const T
727729
return {CreateAlterTable(id, tx)};
728730
}
729731

732+
if (path.IsBackupTable()) {
733+
return {CreateAlterTable(id, tx)};
734+
}
735+
730736
TPath parent = path.Parent();
731737

732738
if (!parent.IsTableIndex()) {

ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class TNewCdcStream: public TSubOperation {
131131
.IsResolved()
132132
.NotDeleted()
133133
.IsTable()
134+
.NotBackupTable()
134135
.NotAsyncReplicaTable()
135136
.NotUnderDeleting();
136137

ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ class TCreateTableIndex: public TSubOperation {
139139
.NotDeleted()
140140
.NotUnderDeleting()
141141
.IsCommonSensePath()
142-
.IsTable();
142+
.IsTable()
143+
.NotBackupTable();
143144

144145
if (!internal) {
145146
checks.NotAsyncReplicaTable();

ydb/core/tx/schemeshard/schemeshard__operation_create_sequence.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ class TCreateSequence : public TSubOperation {
393393

394394
if (checks) {
395395
if (parentPath->IsTable()) {
396+
checks.NotBackupTable();
396397
// allow immediately inside a normal table
397398
if (parentPath.IsUnderOperation()) {
398399
checks.IsUnderTheSameOperation(OperationId.GetTxId()); // allowed only as part of consistent operations

ydb/core/tx/schemeshard/ut_base/ut_base.cpp

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3597,6 +3597,35 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) {
35973597
NLs::IsBackupTable(true),
35983598
});
35993599

3600+
// cannot alter backup table
3601+
TestAlterTable(runtime, ++txId, "/MyRoot", R"(
3602+
Name: "CopyTable"
3603+
DropColumns { Name: "value" }
3604+
)", {NKikimrScheme::StatusSchemeError});
3605+
3606+
// cannot add cdc stream to backup table
3607+
TestCreateCdcStream(runtime, ++txId, "/MyRoot", R"(
3608+
TableName: "CopyTable"
3609+
StreamDescription {
3610+
Name: "Stream"
3611+
Mode: ECdcStreamModeKeysOnly
3612+
Format: ECdcStreamFormatProto
3613+
}
3614+
)", {NKikimrScheme::StatusSchemeError});
3615+
3616+
// cannot add sequence to backup table
3617+
TestCreateSequence(runtime, ++txId, "/MyRoot/CopyTable", R"(
3618+
Name: "Sequence"
3619+
)", {NKikimrScheme::StatusSchemeError});
3620+
3621+
// cannot add index to backup table
3622+
TestBuildIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/CopyTable", "Index", {"value"});
3623+
env.TestWaitNotification(runtime, txId);
3624+
{
3625+
auto desc = TestGetBuildIndex(runtime, TTestTxConfig::SchemeShard, "/MyRoot", txId);
3626+
UNIT_ASSERT_EQUAL(desc.GetIndexBuild().GetState(), Ydb::Table::IndexBuildState::STATE_REJECTED);
3627+
}
3628+
36003629
// consistent copy table
36013630
TestConsistentCopyTables(runtime, ++txId, "/", R"(
36023631
CopyTableDescriptions {
@@ -3735,16 +3764,18 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) {
37353764
)", {NKikimrScheme::StatusInvalidParameter});
37363765

37373766
// cannot remove 'IsBackup' property from existent table
3738-
TestAlterTable(runtime, ++txId, "/MyRoot", R"(
3767+
AsyncSend(runtime, TTestTxConfig::SchemeShard, InternalTransaction(AlterTableRequest(++txId, "/MyRoot", R"(
37393768
Name: "CopyTable"
37403769
IsBackup: false
3741-
)", {NKikimrScheme::StatusInvalidParameter});
3770+
)")));
3771+
TestModificationResults(runtime, txId, {NKikimrScheme::StatusInvalidParameter});
37423772

3743-
TestAlterTable(runtime, ++txId, "/MyRoot", R"(
3773+
AsyncSend(runtime, TTestTxConfig::SchemeShard, InternalTransaction(AlterTableRequest(++txId, "/MyRoot", R"(
37443774
Name: "CopyTable"
37453775
IsBackup: false
37463776
DropColumns { Name: "value" }
3747-
)", {NKikimrScheme::StatusInvalidParameter});
3777+
)")));
3778+
TestModificationResults(runtime, txId, {NKikimrScheme::StatusInvalidParameter});
37483779

37493780
// sanity check
37503781

0 commit comments

Comments
 (0)