diff options
author | Sema Checherinda <checherinda@gmail.com> | 2022-06-16 16:10:18 +0300 |
---|---|---|
committer | Sema Checherinda <checherinda@gmail.com> | 2022-06-16 16:10:18 +0300 |
commit | 572ded33554f05c3eef8e344145ed401b2c2e4c7 (patch) | |
tree | 7e5bfe0bd16c43d7de202f5314543edfd0b7c2a3 | |
parent | 59ddda3782fe5a0c698326a3f00467e0704a630f (diff) | |
download | ydb-572ded33554f05c3eef8e344145ed401b2c2e4c7.tar.gz |
KIKIMR-15126 lost name after move
ref:462bd54a030e34cc5e288ea2ed059758d41d9f24
-rw-r--r-- | ydb/core/tx/datashard/datashard_user_table.cpp | 11 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/ut_move_reboots.cpp | 62 |
2 files changed, 65 insertions, 8 deletions
diff --git a/ydb/core/tx/datashard/datashard_user_table.cpp b/ydb/core/tx/datashard/datashard_user_table.cpp index 8715ee23d2..b7112cd6f9 100644 --- a/ydb/core/tx/datashard/datashard_user_table.cpp +++ b/ydb/core/tx/datashard/datashard_user_table.cpp @@ -16,7 +16,7 @@ TUserTable::TUserTable(ui32 localTid, const NKikimrSchemeOp::TTableDescription& , ShadowTid(shadowTid) { Y_PROTOBUF_SUPPRESS_NODISCARD descr.SerializeToString(&Schema); - Name = descr.GetName(); + Name = ExtractBase(descr.GetPath()); Path = descr.GetPath(); ParseProto(descr); } @@ -31,12 +31,7 @@ TUserTable::TUserTable(const TUserTable& table, const NKikimrSchemeOp::TTableDes void TUserTable::SetPath(const TString &path) { - auto name = ExtractBase(path); - if (!name) { - return; - } - - Name = name; + Name = ExtractBase(path); Path = path; AlterSchema(); } @@ -346,7 +341,7 @@ void TUserTable::AlterSchema() { schema.SetPartitionRangeEnd(Range.To.GetBuffer()); schema.SetPartitionRangeEndIsInclusive(Range.ToInclusive); - schema.SetPath(Name); + schema.SetName(Name); schema.SetPath(Path); SetSchema(schema); diff --git a/ydb/core/tx/schemeshard/ut_move_reboots.cpp b/ydb/core/tx/schemeshard/ut_move_reboots.cpp index ad43530351..7edaea585a 100644 --- a/ydb/core/tx/schemeshard/ut_move_reboots.cpp +++ b/ydb/core/tx/schemeshard/ut_move_reboots.cpp @@ -331,5 +331,67 @@ Y_UNIT_TEST_SUITE(TSchemeShardMoveRebootsTest) { } }); } + + Y_UNIT_TEST(AlterAfter) { + TTestWithReboots t; + + t.Run([&](TTestActorRuntime& runtime, bool& activeZone) { + { + TInactiveZone inactive(activeZone); + TestCreateTable(runtime, ++t.TxId, "/MyRoot", R"( + Name: "Table" + Columns { Name: "key" Type: "Uint64" } + Columns { Name: "value" Type: "Utf8" } + KeyColumnNames: ["key"] + )"); + t.TestEnv->TestWaitNotification(runtime, t.TxId); + + // Write some data to the user table + auto fnWriteRow = [&] (ui64 tabletId) { + TString writeQuery = R"( + ( + (let key '( '('key (Uint64 '0)) ) ) + (let value '('('value (Utf8 '281474980010683)) ) ) + (return (AsList (UpdateRow '__user__Table key value) )) + ) + )"; + NKikimrMiniKQL::TResult result; + TString err; + NKikimrProto::EReplyStatus status = LocalMiniKQL(runtime, tabletId, writeQuery, result, err); + UNIT_ASSERT_VALUES_EQUAL(err, ""); + UNIT_ASSERT_VALUES_EQUAL(status, NKikimrProto::EReplyStatus::OK);; + }; + fnWriteRow(TTestTxConfig::FakeHiveTablets); + + TestDescribeResult(DescribePath(runtime, "/MyRoot"), + {NLs::PathExist, + NLs::ChildrenCount(2), + NLs::ShardsInsideDomain(1)}); + + TestMoveTable(runtime, ++t.TxId, "/MyRoot/Table", "/MyRoot/TableMove"); + t.TestEnv->TestWaitNotification(runtime, t.TxId); + } + + t.TestEnv->ReliablePropose(runtime, AlterTableRequest(++t.TxId, "/MyRoot", + R"(Name: "TableMove" Columns { Name: "add" Type: "Utf8" })"), + {NKikimrScheme::StatusAccepted, NKikimrScheme::StatusMultipleModifications, NKikimrScheme::StatusPreconditionFailed}); + t.TestEnv->TestWaitNotification(runtime, t.TxId); + + { + TInactiveZone inactive(activeZone); + TestDescribeResult(DescribePath(runtime, "/MyRoot"), + {NLs::ChildrenCount(2), + NLs::ShardsInsideDomain(1)}); + TestDescribeResult(DescribePath(runtime, "/MyRoot/TableMove"), + {NLs::IsTable, + NLs::PathVersionEqual(7), + NLs::CheckColumns("TableMove", {"key", "value", "add"}, {}, {"key"}), + NLs::PathsInsideDomain(2), + NLs::ShardsInsideDomain(1)}); + TestDescribeResult(DescribePath(runtime, "/MyRoot/Table"), + {NLs::PathNotExist}); + } + }); + } } |