diff options
author | Ilnaz Nizametdinov <i.nizametdinov@gmail.com> | 2022-03-15 14:07:37 +0300 |
---|---|---|
committer | Ilnaz Nizametdinov <i.nizametdinov@gmail.com> | 2022-03-15 14:07:37 +0300 |
commit | 32818af8c94dfd7d693dd93666d7ab50cea14027 (patch) | |
tree | 7f370b6d9d3ec2576b9718c3aee7e542ee00574c | |
parent | a00d7c212095f500fa8240810af56aea94e72394 (diff) | |
download | ydb-32818af8c94dfd7d693dd93666d7ab50cea14027.tar.gz |
CopyTable + TTL = <3 KIKIMR-14491
ref:620a6bc9b60fb60b1307cd11049972e96193a2aa
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard__operation_common.cpp | 2 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp | 5 | ||||
-rw-r--r-- | ydb/core/tx/schemeshard/ut_ttl.cpp | 43 |
3 files changed, 50 insertions, 0 deletions
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_common.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_common.cpp index 5a88636ffa..24423ce1a6 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_common.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_common.cpp @@ -483,6 +483,8 @@ TVector<TTableShardInfo> NTableState::ApplyPartitioningCopyTable(const TShardInf txState.Shards.emplace_back(idx, ETabletType::DataShard, TTxState::CreateParts); // Properly set new shard idx dstPartitions[i].ShardIdx = idx; + // clear lag to avoid counter underflow + dstPartitions[i].LastCondEraseLag.Clear(); } return dstPartitions; diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp index f504c34ef5..f65f7c6f2c 100644 --- a/ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp +++ b/ydb/core/tx/schemeshard/schemeshard__operation_copy_table.cpp @@ -193,6 +193,11 @@ public: context.SS->TabletCounters->Simple()[COUNTER_TABLE_COUNT].Add(1); + if (table->IsTTLEnabled()) { + context.SS->TTLEnabledTables[pathId] = table; + context.SS->TabletCounters->Simple()[COUNTER_TTL_ENABLED_TABLE_COUNT].Add(1); + } + auto parentDir = context.SS->PathsById.at(path->ParentPathId); // TargetPathId has been created ++parentDir->DirAlterVersion; context.SS->PersistPathDirAlterVersion(db, parentDir); diff --git a/ydb/core/tx/schemeshard/ut_ttl.cpp b/ydb/core/tx/schemeshard/ut_ttl.cpp index d512ad0033..c160143b49 100644 --- a/ydb/core/tx/schemeshard/ut_ttl.cpp +++ b/ydb/core/tx/schemeshard/ut_ttl.cpp @@ -617,6 +617,49 @@ Y_UNIT_TEST_SUITE(TSchemeShardTTLTests) { NKqp::CompareYson(R"([[[[[["2"]]];%false]]])", result); } } + + { + ++tabletId; + TestConsistentCopyTables(runtime, ++txId, "/", R"( + CopyTableDescriptions { + SrcPath: "/MyRoot/TTLEnabledTable4" + DstPath: "/MyRoot/TTLEnabledTable5" + } + )"); + env.TestWaitNotification(runtime, txId); + + writeRow(tabletId, 1, now, "TTLEnabledTable5", "Uint64"); + { + auto result = readTable(tabletId, "TTLEnabledTable5"); + NKqp::CompareYson(R"([[[[[["1"]];[["2"]]];%false]]])", result); + } + + runtime.AdvanceCurrentTime(TDuration::Hours(1)); + WaitForCondErase(runtime); + { + auto result = readTable(tabletId, "TTLEnabledTable5"); + NKqp::CompareYson(R"([[[[[["2"]]];%false]]])", result); + } + } + + { + ++tabletId; + TestCopyTable(runtime, ++txId, "/MyRoot", "TTLEnabledTable6", "/MyRoot/TTLEnabledTable5"); + env.TestWaitNotification(runtime, txId); + + writeRow(tabletId, 1, now, "TTLEnabledTable6", "Uint64"); + { + auto result = readTable(tabletId, "TTLEnabledTable6"); + NKqp::CompareYson(R"([[[[[["1"]];[["2"]]];%false]]])", result); + } + + runtime.AdvanceCurrentTime(TDuration::Hours(1)); + WaitForCondErase(runtime); + { + auto result = readTable(tabletId, "TTLEnabledTable6"); + NKqp::CompareYson(R"([[[[[["2"]]];%false]]])", result); + } + } } Y_UNIT_TEST(RacyAlterTableAndConditionalErase) { |