aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorilnaz <ilnaz@ydb.tech>2023-04-20 13:10:27 +0300
committerilnaz <ilnaz@ydb.tech>2023-04-20 13:10:27 +0300
commitbd74b9aa12ecebc467d45a08ad0cd5ede7ad6b31 (patch)
tree603c26bd7cb3bfd256cdae9771a2ab6afd7b3200
parentec57b10d0e2cbd278c9bab1315504e5d6dc4f331 (diff)
downloadydb-bd74b9aa12ecebc467d45a08ad0cd5ede7ad6b31.tar.gz
Forbid scheme transactions on replicated tables
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_cdc_stream.cpp3
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_index.cpp3
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_alter_table.cpp1
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_backup_restore_common.h1
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp3
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp3
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_create_lock.cpp1
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_cdc_stream.cpp3
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_drop_index.cpp2
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_move_index.cpp2
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp1
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp1
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_move_tables.cpp1
-rw-r--r--ydb/core/tx/schemeshard/schemeshard_build_index__create.cpp1
-rw-r--r--ydb/core/tx/schemeshard/schemeshard_info_types.h9
-rw-r--r--ydb/core/tx/schemeshard/schemeshard_path.cpp29
-rw-r--r--ydb/core/tx/schemeshard/schemeshard_path.h2
-rw-r--r--ydb/core/tx/schemeshard/ut_replication.cpp17
18 files changed, 77 insertions, 6 deletions
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_cdc_stream.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_cdc_stream.cpp
index fe66156e886..7ec3b8c1f2c 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_cdc_stream.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_cdc_stream.cpp
@@ -138,6 +138,7 @@ public:
.IsResolved()
.NotDeleted()
.IsTable()
+ .NotAsyncReplicaTable()
.IsCommonSensePath()
.NotUnderOperation();
@@ -364,6 +365,7 @@ public:
.IsResolved()
.NotDeleted()
.IsTable()
+ .NotAsyncReplicaTable()
.IsCommonSensePath()
.NotUnderDeleting()
.NotUnderOperation();
@@ -508,6 +510,7 @@ TVector<ISubOperation::TPtr> CreateAlterCdcStream(TOperationId opId, const TTxTr
.IsResolved()
.NotDeleted()
.IsTable()
+ .NotAsyncReplicaTable()
.IsCommonSensePath()
.NotUnderOperation();
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_index.cpp
index 06dd6545f79..4e6f10a920f 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_index.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_index.cpp
@@ -140,7 +140,8 @@ public:
.NotDeleted()
.NotUnderDeleting()
.IsCommonSensePath()
- .IsTable();
+ .IsTable()
+ .NotAsyncReplicaTable();
if (!checks) {
result->SetError(checks.GetStatus(), checks.GetError());
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_alter_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_alter_table.cpp
index b1faeb20b15..78b0e4d56eb 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_alter_table.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_alter_table.cpp
@@ -489,6 +489,7 @@ public:
.IsResolved()
.NotDeleted()
.IsTable()
+ .NotAsyncReplicaTable()
.NotUnderOperation();
if (!context.IsAllowedPrivateTables) {
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_backup_restore_common.h b/ydb/core/tx/schemeshard/schemeshard__operation_backup_restore_common.h
index 269c8400909..c7fadcec470 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_backup_restore_common.h
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_backup_restore_common.h
@@ -605,6 +605,7 @@ public:
.IsResolved()
.NotDeleted()
.IsTable()
+ .NotAsyncReplicaTable()
.NotUnderOperation()
.IsCommonSensePath() //forbid alter impl index tables
.NotChildren(); //forbid backup table with indexes
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp
index 9a38a3651b5..4fd6b490db0 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_cdc_stream.cpp
@@ -128,6 +128,7 @@ public:
.IsResolved()
.NotDeleted()
.IsTable()
+ .NotAsyncReplicaTable()
.IsCommonSensePath()
.NotUnderDeleting();
@@ -477,6 +478,7 @@ public:
.IsResolved()
.NotDeleted()
.IsTable()
+ .NotAsyncReplicaTable()
.IsCommonSensePath()
.NotUnderDeleting();
@@ -608,6 +610,7 @@ TVector<ISubOperation::TPtr> CreateNewCdcStream(TOperationId opId, const TTxTran
.IsResolved()
.NotDeleted()
.IsTable()
+ .NotAsyncReplicaTable()
.IsCommonSensePath()
.NotUnderDeleting()
.NotUnderOperation();
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp
index f5f2a508f04..7e0f7048e53 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_index.cpp
@@ -138,7 +138,8 @@ public:
.NotDeleted()
.NotUnderDeleting()
.IsCommonSensePath()
- .IsTable();
+ .IsTable()
+ .NotAsyncReplicaTable();
if (tableIndexCreation.GetState() == NKikimrSchemeOp::EIndexState::EIndexStateReady) {
checks
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_create_lock.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_create_lock.cpp
index 383a8ceb432..656c65f2b67 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_create_lock.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_create_lock.cpp
@@ -143,6 +143,7 @@ public:
.NotUnderDeleting()
.NotUnderOperation()
.IsTable()
+ .NotAsyncReplicaTable()
.IsCommonSensePath();
if (!checks) {
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_cdc_stream.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_cdc_stream.cpp
index fcdef20e4d8..c162b14d9f5 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_cdc_stream.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_cdc_stream.cpp
@@ -145,6 +145,7 @@ public:
.IsResolved()
.NotDeleted()
.IsTable()
+ .NotAsyncReplicaTable()
.IsCommonSensePath()
.IsUnderOperation()
.IsUnderTheSameOperation(OperationId.GetTxId());
@@ -326,6 +327,7 @@ public:
.IsResolved()
.NotDeleted()
.IsTable()
+ .NotAsyncReplicaTable()
.IsCommonSensePath()
.NotUnderDeleting()
.NotUnderOperation();
@@ -470,6 +472,7 @@ TVector<ISubOperation::TPtr> CreateDropCdcStream(TOperationId opId, const TTxTra
.IsResolved()
.NotDeleted()
.IsTable()
+ .NotAsyncReplicaTable()
.IsCommonSensePath()
.NotUnderDeleting()
.NotUnderOperation();
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_drop_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_drop_index.cpp
index 06324a4999c..695a487e661 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_drop_index.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_drop_index.cpp
@@ -282,6 +282,7 @@ public:
.NotDeleted()
.NotUnderDeleting()
.IsTable()
+ .NotAsyncReplicaTable()
.NotUnderOperation()
.IsCommonSensePath();
@@ -416,6 +417,7 @@ TVector<ISubOperation::TPtr> CreateDropIndex(TOperationId nextId, const TTxTrans
.IsResolved()
.NotDeleted()
.IsTable()
+ .NotAsyncReplicaTable()
.NotUnderDeleting()
.NotUnderOperation()
.IsCommonSensePath();
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_move_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_move_index.cpp
index 33813413293..63d8b743279 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_move_index.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_move_index.cpp
@@ -380,6 +380,7 @@ public:
.NotDeleted()
.NotUnderDeleting()
.IsTable()
+ .NotAsyncReplicaTable()
.NotUnderOperation()
.IsCommonSensePath();
@@ -489,6 +490,7 @@ TVector<ISubOperation::TPtr> CreateConsistentMoveIndex(TOperationId nextId, cons
.IsResolved()
.NotDeleted()
.IsTable()
+ .NotAsyncReplicaTable()
.NotUnderDeleting()
.NotUnderOperation()
.IsCommonSensePath();
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp
index d2f73bc6cd4..58929e24c46 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_move_table.cpp
@@ -580,6 +580,7 @@ public:
.NotDeleted()
.IsTable()
.NotBackupTable()
+ .NotAsyncReplicaTable()
.NotUnderTheSameOperation(OperationId.GetTxId())
.NotUnderOperation();
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp
index 19deb8714b2..fec522a9c4b 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_move_table_index.cpp
@@ -385,6 +385,7 @@ public:
.NotUnderDeleting()
.IsCommonSensePath()
.IsTable()
+ .NotAsyncReplicaTable()
.IsUnderTheSameOperation(OperationId.GetTxId());
if (!checks) {
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_move_tables.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_move_tables.cpp
index dd35cd1faf1..4e5c1429b8e 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_move_tables.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_move_tables.cpp
@@ -33,6 +33,7 @@ TVector<ISubOperation::TPtr> CreateConsistentMoveTable(TOperationId nextId, cons
checks.IsResolved()
.NotDeleted()
.IsTable()
+ .NotAsyncReplicaTable()
.IsCommonSensePath();
if (!checks) {
diff --git a/ydb/core/tx/schemeshard/schemeshard_build_index__create.cpp b/ydb/core/tx/schemeshard/schemeshard_build_index__create.cpp
index 55971d9a5cc..e6a33ac9eee 100644
--- a/ydb/core/tx/schemeshard/schemeshard_build_index__create.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard_build_index__create.cpp
@@ -88,6 +88,7 @@ public:
.NotDeleted()
.NotUnderDeleting()
.IsTable()
+ .NotAsyncReplicaTable()
.IsCommonSensePath()
.IsTheSameDomain(domainPath);
diff --git a/ydb/core/tx/schemeshard/schemeshard_info_types.h b/ydb/core/tx/schemeshard/schemeshard_info_types.h
index ad5ae6a118a..418df0824ff 100644
--- a/ydb/core/tx/schemeshard/schemeshard_info_types.h
+++ b/ydb/core/tx/schemeshard/schemeshard_info_types.h
@@ -419,6 +419,15 @@ struct TTableInfo : public TSimpleRefCount<TTableInfo> {
const NKikimrSchemeOp::TTableReplicationConfig& ReplicationConfig() { return TableDescription.GetReplicationConfig(); }
NKikimrSchemeOp::TTableReplicationConfig& MutableReplicationConfig() { return *TableDescription.MutableReplicationConfig(); }
+ bool IsAsyncReplica() const {
+ switch (TableDescription.GetReplicationConfig().GetMode()) {
+ case NKikimrSchemeOp::TTableReplicationConfig::REPLICATION_MODE_NONE:
+ return false;
+ default:
+ return true;
+ }
+ }
+
bool HasTTLSettings() const { return TableDescription.HasTTLSettings(); }
const NKikimrSchemeOp::TTTLSettings& TTLSettings() const { return TableDescription.GetTTLSettings(); }
bool IsTTLEnabled() const { return HasTTLSettings() && TTLSettings().HasEnabled(); }
diff --git a/ydb/core/tx/schemeshard/schemeshard_path.cpp b/ydb/core/tx/schemeshard/schemeshard_path.cpp
index 755308f0a28..685e7837a5d 100644
--- a/ydb/core/tx/schemeshard/schemeshard_path.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard_path.cpp
@@ -366,6 +366,23 @@ const TPath::TChecker& TPath::TChecker::NotBackupTable(EStatus status) const {
<< " (" << BasicPathInfo(Path.Base()) << ")");
}
+const TPath::TChecker& TPath::TChecker::NotAsyncReplicaTable(EStatus status) const {
+ if (Failed) {
+ return *this;
+ }
+
+ if (!Path.Base()->IsTable()) {
+ return *this;
+ }
+
+ if (!Path.IsAsyncReplicaTable()) {
+ return *this;
+ }
+
+ return Fail(status, TStringBuilder() << "path is an async replica table"
+ << " (" << BasicPathInfo(Path.Base()) << ")");
+}
+
const TPath::TChecker& TPath::TChecker::IsBlockStoreVolume(EStatus status) const {
if (Failed) {
return *this;
@@ -1416,6 +1433,18 @@ bool TPath::IsBackupTable() const {
return tableInfo->IsBackup;
}
+bool TPath::IsAsyncReplicaTable() const {
+ Y_VERIFY(IsResolved());
+
+ if (!Base()->IsTable() || !SS->Tables.contains(Base()->PathId)) {
+ return false;
+ }
+
+ TTableInfo::TCPtr tableInfo = SS->Tables.at(Base()->PathId);
+
+ return tableInfo->IsAsyncReplica();
+}
+
bool TPath::IsCdcStream() const {
Y_VERIFY(IsResolved());
diff --git a/ydb/core/tx/schemeshard/schemeshard_path.h b/ydb/core/tx/schemeshard/schemeshard_path.h
index 88dcd3c5bc5..89a76b2867d 100644
--- a/ydb/core/tx/schemeshard/schemeshard_path.h
+++ b/ydb/core/tx/schemeshard/schemeshard_path.h
@@ -60,6 +60,7 @@ public:
const TChecker& IsInsideCdcStreamPath(EStatus status = EStatus::StatusNameConflict) const;
const TChecker& IsTable(EStatus status = EStatus::StatusNameConflict) const;
const TChecker& NotBackupTable(EStatus status = EStatus::StatusSchemeError) const;
+ const TChecker& NotAsyncReplicaTable(EStatus status = EStatus::StatusSchemeError) const;
const TChecker& IsBlockStoreVolume(EStatus status = EStatus::StatusNameConflict) const;
const TChecker& IsFileStore(EStatus status = EStatus::StatusNameConflict) const;
const TChecker& IsKesus(EStatus status = EStatus::StatusNameConflict) const;
@@ -149,6 +150,7 @@ public:
bool IsInsideCdcStreamPath() const;
bool IsTableIndex() const;
bool IsBackupTable() const;
+ bool IsAsyncReplicaTable() const;
bool IsCdcStream() const;
bool IsSequence() const;
bool IsReplication() const;
diff --git a/ydb/core/tx/schemeshard/ut_replication.cpp b/ydb/core/tx/schemeshard/ut_replication.cpp
index 8107c059cdb..c1a50fa5170 100644
--- a/ydb/core/tx/schemeshard/ut_replication.cpp
+++ b/ydb/core/tx/schemeshard/ut_replication.cpp
@@ -163,7 +163,7 @@ Y_UNIT_TEST_SUITE(TReplicationTests) {
CreateReplicatedTable(NKikimrSchemeOp::TTableReplicationConfig::REPLICATION_MODE_READ_ONLY);
}
- Y_UNIT_TEST(AlterReplicationConfig) {
+ Y_UNIT_TEST(AlterReplicatedTable) {
TTestBasicRuntime runtime;
TTestEnv env(runtime);
ui64 txId = 100;
@@ -182,10 +182,19 @@ Y_UNIT_TEST_SUITE(TReplicationTests) {
TestAlterTable(runtime, ++txId, "/MyRoot", R"(
Name: "Table"
DropColumns { Name: "value" }
- ReplicationConfig {
- Mode: REPLICATION_MODE_NONE
+ )", {NKikimrScheme::StatusSchemeError});
+
+ TestCreateCdcStream(runtime, ++txId, "/MyRoot", R"(
+ TableName: "Table"
+ StreamDescription {
+ Name: "Stream"
+ Mode: ECdcStreamModeKeysOnly
+ Format: ECdcStreamFormatProto
}
- )", {NKikimrScheme::StatusInvalidParameter});
+ )", {NKikimrScheme::StatusSchemeError});
+
+ TestBuildIndex(runtime, ++txId, TTestTxConfig::SchemeShard, "/MyRoot", "/MyRoot/Table", "by_value", {"value"},
+ Ydb::StatusIds::BAD_REQUEST);
}
Y_UNIT_TEST(CopyReplicatedTable) {