aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorilnaz <ilnaz@ydb.tech>2022-08-24 15:19:55 +0300
committerilnaz <ilnaz@ydb.tech>2022-08-24 15:19:55 +0300
commit653146b941fae8faaf0cf733e371816e7c69e7d2 (patch)
tree66891e5503587fe129dddcaccb59b6c717c3a15a
parent81b0f9dfa1c7c7f19d14d7300459b11314e43ffb (diff)
downloadydb-653146b941fae8faaf0cf733e371816e7c69e7d2.tar.gz
Just remove shard from BackupShards too (without checks)
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__delete_tablet_reply.cpp2
-rw-r--r--ydb/core/tx/schemeshard/schemeshard__operation_common.cpp2
-rw-r--r--ydb/core/tx/schemeshard/schemeshard_info_types.h7
-rw-r--r--ydb/core/tx/schemeshard/ut_base.cpp42
4 files changed, 46 insertions, 7 deletions
diff --git a/ydb/core/tx/schemeshard/schemeshard__delete_tablet_reply.cpp b/ydb/core/tx/schemeshard/schemeshard__delete_tablet_reply.cpp
index 5e45475c9f1..d5c39e7d7ba 100644
--- a/ydb/core/tx/schemeshard/schemeshard__delete_tablet_reply.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__delete_tablet_reply.cpp
@@ -126,7 +126,7 @@ struct TSchemeShard::TTxDeleteTabletReply : public TSchemeShard::TRwTxBase {
path->DecShardsInside();
auto domain = Self->ResolveDomainInfo(path);
- domain->RemoveInternalShard(ShardIdx, Self->IsBackupTable(pathId));
+ domain->RemoveInternalShard(ShardIdx);
switch (tabletType) {
case ETabletType::SequenceShard:
domain->RemoveSequenceShard(ShardIdx);
diff --git a/ydb/core/tx/schemeshard/schemeshard__operation_common.cpp b/ydb/core/tx/schemeshard/schemeshard__operation_common.cpp
index cdb777eaede..4ef28ff9265 100644
--- a/ydb/core/tx/schemeshard/schemeshard__operation_common.cpp
+++ b/ydb/core/tx/schemeshard/schemeshard__operation_common.cpp
@@ -394,7 +394,7 @@ void NTableState::UpdatePartitioningForCopyTable(TOperationId operationId, TTxSt
dstTableInfo->PerShardPartitionConfig.erase(shard.Idx);
context.SS->PersistShardDeleted(db, shard.Idx, context.SS->ShardInfos[shard.Idx].BindedChannels);
context.SS->ShardInfos.erase(shard.Idx);
- domainInfo->RemoveInternalShard(shard.Idx, context.SS->IsBackupTable(pathId));
+ domainInfo->RemoveInternalShard(shard.Idx);
context.SS->DecrementPathDbRefCount(pathId, "remove shard from txState");
context.SS->ShardRemoved(shard.Idx);
}
diff --git a/ydb/core/tx/schemeshard/schemeshard_info_types.h b/ydb/core/tx/schemeshard/schemeshard_info_types.h
index c094e1540ad..4595022733a 100644
--- a/ydb/core/tx/schemeshard/schemeshard_info_types.h
+++ b/ydb/core/tx/schemeshard/schemeshard_info_types.h
@@ -1638,14 +1638,11 @@ struct TSubDomainInfo: TSimpleRefCount<TSubDomainInfo> {
}
}
- void RemoveInternalShard(TShardIdx shardIdx, bool isBackup = false) {
+ void RemoveInternalShard(TShardIdx shardIdx) {
auto it = InternalShards.find(shardIdx);
Y_VERIFY_S(it != InternalShards.end(), "shardIdx: " << shardIdx);
InternalShards.erase(it);
-
- if (isBackup) {
- BackupShards.erase(shardIdx);
- }
+ BackupShards.erase(shardIdx);
}
const THashSet<TShardIdx>& GetSequenceShards() const {
diff --git a/ydb/core/tx/schemeshard/ut_base.cpp b/ydb/core/tx/schemeshard/ut_base.cpp
index e883604f181..62e98f3be54 100644
--- a/ydb/core/tx/schemeshard/ut_base.cpp
+++ b/ydb/core/tx/schemeshard/ut_base.cpp
@@ -3488,6 +3488,18 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) {
TTestEnv env(runtime);
ui64 txId = 100;
+ // used to sanity check at the end of the test
+ THashSet<ui64> deletedShardIdxs;
+ runtime.SetObserverFunc([&](TTestActorRuntimeBase&, TAutoPtr<IEventHandle>& ev) {
+ if (ev->GetTypeRewrite() == TEvHive::EvDeleteTabletReply) {
+ for (const ui64 shardIdx : ev->Get<TEvHive::TEvDeleteTabletReply>()->Record.GetShardLocalIdx()) {
+ deletedShardIdxs.insert(shardIdx);
+ }
+ }
+
+ return TTestActorRuntime::EEventAction::PROCESS;
+ });
+
// these limits should have no effect on backup tables
TSchemeLimits limits;
limits.MaxPaths = 4;
@@ -3644,6 +3656,36 @@ Y_UNIT_TEST_SUITE(TSchemeShardTest) {
IsBackup: false
DropColumns { Name: "value" }
)", {NKikimrScheme::StatusInvalidParameter});
+
+ // sanity check
+
+ // drop all tables
+ TVector<ui64> dropTxIds;
+ for (const auto& table : {"Table", "CopyTable", "ConsistentCopyTable"}) {
+ TestDropTable(runtime, dropTxIds.emplace_back(++txId), "/MyRoot", table);
+ }
+ for (const auto& table : {"Table3", "Table4"}) {
+ TestDropTable(runtime, dropTxIds.emplace_back(++txId), "/MyRoot/Dir", table);
+ }
+ // Table2 has already been dropped
+ env.TestWaitNotification(runtime, dropTxIds);
+
+ if (deletedShardIdxs.size() != 6) { // 6 tables with one shard each
+ TDispatchOptions opts;
+ opts.FinalEvents.emplace_back([&deletedShardIdxs](IEventHandle&) {
+ return deletedShardIdxs.size() == 6;
+ });
+ runtime.DispatchEvents(opts);
+ }
+
+ // ok
+ TestCreateTable(runtime, ++txId, "/MyRoot", R"(
+ Name: "Table"
+ Columns { Name: "key" Type: "Uint32"}
+ Columns { Name: "value" Type: "Utf8"}
+ KeyColumnNames: ["key"]
+ )");
+ env.TestWaitNotification(runtime, txId);
}
Y_UNIT_TEST(AlterTableAndConcurrentSplit) { //+