aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlnaz Nizametdinov <i.nizametdinov@gmail.com>2022-04-21 19:33:05 +0300
committerIlnaz Nizametdinov <i.nizametdinov@gmail.com>2022-04-21 19:33:05 +0300
commit85102d16584d579d7448da093f137fc149258813 (patch)
tree43afab2daba5dd653fe32464b2d7cbbe4d99df44
parenta825f9513617cb6e50147fb031596bc801e24957 (diff)
downloadydb-85102d16584d579d7448da093f137fc149258813.tar.gz
MoveTable() test KIKIMR-13698
ref:dbf6a6c92001cb5aed7e65a889a55622eb75bd6a
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_move_tables.cpp22
-rw-r--r--ydb/core/tx/schemeshard/ut_cdc_stream.cpp26
2 files changed, 39 insertions, 9 deletions
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_move_tables.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_move_tables.cpp
index c133ce1adf2..bcca666ffd0 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_move_tables.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_move_tables.cpp
@@ -92,27 +92,31 @@ TVector<ISubOperationBase::TPtr> CreateConsistentMoveTable(TOperationId nextId,
for (auto& child: srcPath.Base()->GetChildren()) {
auto name = child.first;
- TPath srcIndexPath = srcPath.Child(name);
- if (srcIndexPath.IsDeleted()) {
+ TPath srcChildPath = srcPath.Child(name);
+ if (srcChildPath.IsDeleted()) {
continue;
}
+ if (srcChildPath.IsCdcStream()) {
+ return {CreateReject(nextId, NKikimrScheme::StatusPreconditionFailed, "Cannot move table with cdc streams")};
+ }
+
TPath dstIndexPath = dstPath.Child(name);
- Y_VERIFY(srcIndexPath.Base()->PathId == child.second);
- Y_VERIFY_S(srcIndexPath.Base()->GetChildren().size() == 1,
- srcIndexPath.PathString() << " has children " << srcIndexPath.Base()->GetChildren().size());
+ Y_VERIFY(srcChildPath.Base()->PathId == child.second);
+ Y_VERIFY_S(srcChildPath.Base()->GetChildren().size() == 1,
+ srcChildPath.PathString() << " has children " << srcChildPath.Base()->GetChildren().size());
result.push_back(CreateMoveTableIndex(TOperationId(nextId.GetTxId(),
nextId.GetSubTxId() + result.size()),
- MoveTableIndexTask(srcIndexPath, dstIndexPath)));
+ MoveTableIndexTask(srcChildPath, dstIndexPath)));
- TString srcImplTableName = srcIndexPath.Base()->GetChildren().begin()->first;
- TPath srcImplTable = srcIndexPath.Child(srcImplTableName);
+ TString srcImplTableName = srcChildPath.Base()->GetChildren().begin()->first;
+ TPath srcImplTable = srcChildPath.Child(srcImplTableName);
if (srcImplTable.IsDeleted()) {
continue;
}
- Y_VERIFY(srcImplTable.Base()->PathId == srcIndexPath.Base()->GetChildren().begin()->second);
+ Y_VERIFY(srcImplTable.Base()->PathId == srcChildPath.Base()->GetChildren().begin()->second);
TPath dstImplTable = dstIndexPath.Child(srcImplTableName);
diff --git a/ydb/core/tx/schemeshard/ut_cdc_stream.cpp b/ydb/core/tx/schemeshard/ut_cdc_stream.cpp
index e2b6dcd052f..78d1ec2bfd9 100644
--- a/ydb/core/tx/schemeshard/ut_cdc_stream.cpp
+++ b/ydb/core/tx/schemeshard/ut_cdc_stream.cpp
@@ -441,6 +441,32 @@ Y_UNIT_TEST_SUITE(TCdcStreamTests) {
TestDescribeResult(DescribePrivatePath(runtime, "/MyRoot/TableCopy/Stream"), {NLs::PathNotExist});
}
+ Y_UNIT_TEST(MoveTableShouldFail) {
+ TTestBasicRuntime runtime;
+ TTestEnv env(runtime, TTestEnvOptions().EnableProtoSourceIdInfo(true));
+ ui64 txId = 100;
+
+ TestCreateTable(runtime, ++txId, "/MyRoot", R"(
+ Name: "Table"
+ Columns { Name: "key" Type: "Uint64" }
+ Columns { Name: "value" Type: "Uint64" }
+ KeyColumnNames: ["key"]
+ )");
+ env.TestWaitNotification(runtime, txId);
+
+ TestCreateCdcStream(runtime, ++txId, "/MyRoot", R"(
+ TableName: "Table"
+ StreamDescription {
+ Name: "Stream"
+ Mode: ECdcStreamModeKeysOnly
+ Format: ECdcStreamFormatProto
+ }
+ )");
+ env.TestWaitNotification(runtime, txId);
+
+ TestMoveTable(runtime, ++txId, "/MyRoot/Table", "/MyRoot/TableMoved", {NKikimrScheme::StatusPreconditionFailed});
+ }
+
Y_UNIT_TEST(CheckSchemeLimits) {
TTestBasicRuntime runtime;
TTestEnv env(runtime, TTestEnvOptions().EnableProtoSourceIdInfo(true));