Skip to content

Commit 54775d3

Browse files
authored
Data erasure remove waiting shards (#16313) (#17117)
1 parent 356f091 commit 54775d3

File tree

4 files changed

+19
-45
lines changed

4 files changed

+19
-45
lines changed

ydb/core/tx/schemeshard/schemeshard__delete_tablet_reply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ struct TSchemeShard::TTxDeleteTabletReply : public TSchemeShard::TRwTxBase {
180180
"Close pipe to deleted shardIdx " << ShardIdx << " tabletId " << TabletId);
181181
Self->PipeClientCache->ForceClose(ctx, ui64(TabletId));
182182
}
183-
if (Self->DataErasureManager->GetStatus() == EDataErasureStatus::IN_PROGRESS) {
183+
if (Self->EnableDataErasure && Self->DataErasureManager->GetStatus() == EDataErasureStatus::IN_PROGRESS) {
184184
Self->Execute(Self->CreateTxCancelDataErasureShards({ShardIdx}));
185185
}
186186
}

ydb/core/tx/schemeshard/schemeshard__root_data_erasure_manager.cpp

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -313,22 +313,14 @@ void TRootDataErasureManager::OnDone(const TPathId& pathId, NIceDb::TNiceDb& db)
313313
ActivePipes.erase(pathId);
314314
auto it = WaitingDataErasureTenants.find(pathId);
315315
if (it != WaitingDataErasureTenants.end()) {
316-
it->second = EDataErasureStatus::COMPLETED;
317-
db.Table<Schema::WaitingDataErasureTenants>().Key(pathId.OwnerId, pathId.LocalPathId).Update<Schema::WaitingDataErasureTenants::Status>(it->second);
316+
db.Table<Schema::WaitingDataErasureTenants>().Key(pathId.OwnerId, pathId.LocalPathId).Delete();
317+
WaitingDataErasureTenants.erase(it);
318318
}
319319

320320
SchemeShard->TabletCounters->Cumulative()[COUNTER_DATA_ERASURE_OK].Increment(1);
321321
UpdateMetrics();
322322

323-
bool isDataErasureCompleted = true;
324-
for (const auto& [pathId, status] : WaitingDataErasureTenants) {
325-
if (status == EDataErasureStatus::IN_PROGRESS) {
326-
isDataErasureCompleted = false;
327-
break;
328-
}
329-
}
330-
331-
if (isDataErasureCompleted) {
323+
if (WaitingDataErasureTenants.empty()) {
332324
LOG_INFO_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
333325
"[RootDataErasureManager] Data erasure in tenants is completed. Send request to BS controller");
334326
Status = EDataErasureStatus::IN_PROGRESS_BSC;
@@ -465,16 +457,10 @@ bool TRootDataErasureManager::Remove(const TPathId& pathId) {
465457
if (it != WaitingDataErasureTenants.end()) {
466458
Queue->Remove(pathId);
467459
ActivePipes.erase(pathId);
468-
WaitingDataErasureTenants[pathId] = EDataErasureStatus::COMPLETED;
469-
bool isDataErasureCompleted = true;
470-
for (const auto& [pathId, status] : WaitingDataErasureTenants) {
471-
if (status == EDataErasureStatus::IN_PROGRESS) {
472-
isDataErasureCompleted = false;
473-
break;
474-
}
475-
}
460+
WaitingDataErasureTenants.erase(it);
476461

477-
if (isDataErasureCompleted) {
462+
if (WaitingDataErasureTenants.empty()) {
463+
Status = EDataErasureStatus::IN_PROGRESS_BSC;
478464
SendRequestToBSC();
479465
}
480466
return true;

ydb/core/tx/schemeshard/schemeshard__tenant_data_erasure_manager.cpp

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void TTenantDataErasureManager::Run(NIceDb::TNiceDb& db) {
114114
Status = EDataErasureStatus::IN_PROGRESS;
115115
for (const auto& [shardIdx, shardInfo] : SchemeShard->ShardInfos) {
116116
if (shardInfo.TabletType == ETabletType::DataShard) {
117-
Enqueue(shardIdx); // forward generation
117+
Enqueue(shardIdx);
118118
WaitingDataErasureShards[shardIdx] = EDataErasureStatus::IN_PROGRESS;
119119
db.Table<Schema::WaitingDataErasureShards>().Key(shardIdx.GetOwnerId(), shardIdx.GetLocalId()).Update<Schema::WaitingDataErasureShards::Status>(WaitingDataErasureShards[shardIdx]);
120120
}
@@ -291,21 +291,15 @@ void TTenantDataErasureManager::OnDone(const TTabletId& tabletId, NIceDb::TNiceD
291291
{
292292
auto it = WaitingDataErasureShards.find(shardIdx);
293293
if (it != WaitingDataErasureShards.end()) {
294-
it->second = EDataErasureStatus::COMPLETED;
294+
db.Table<Schema::WaitingDataErasureShards>().Key(shardIdx.GetOwnerId(), shardIdx.GetLocalId()).Delete();
295+
WaitingDataErasureShards.erase(it);
295296
}
296-
db.Table<Schema::WaitingDataErasureShards>().Key(shardIdx.GetOwnerId(), shardIdx.GetLocalId()).Update<Schema::WaitingDataErasureShards::Status>(it->second);
297297
}
298298

299299
SchemeShard->TabletCounters->Cumulative()[COUNTER_TENANT_DATA_ERASURE_OK].Increment(1);
300300
UpdateMetrics();
301301

302-
bool isTenantDataErasureCompleted = true;
303-
for (const auto& [shardIdx, status] : WaitingDataErasureShards) {
304-
if (status == EDataErasureStatus::IN_PROGRESS) {
305-
isTenantDataErasureCompleted = false;
306-
}
307-
}
308-
if (isTenantDataErasureCompleted) {
302+
if (WaitingDataErasureShards.empty()) {
309303
LOG_INFO_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
310304
"[TenantDataErasureManager] Data erasure in shards is completed. Send response to root schemeshard");
311305
Complete();
@@ -399,14 +393,8 @@ bool TTenantDataErasureManager::Remove(const TShardIdx& shardIdx) {
399393
if (it != WaitingDataErasureShards.end()) {
400394
Queue->Remove(shardIdx);
401395
ActivePipes.erase(shardIdx);
402-
it->second = EDataErasureStatus::COMPLETED;
403-
bool isTenantDataErasureCompleted = true;
404-
for (const auto& [shardIdx, status] : WaitingDataErasureShards) {
405-
if (status == EDataErasureStatus::IN_PROGRESS) {
406-
isTenantDataErasureCompleted = false;
407-
}
408-
}
409-
if (isTenantDataErasureCompleted) {
396+
WaitingDataErasureShards.erase(it);
397+
if (WaitingDataErasureShards.empty()) {
410398
auto ctx = SchemeShard->ActorContext();
411399
LOG_INFO_S(ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
412400
"[TenantDataErasureManager] [Remove] Data erasure in shards is completed. Send response to root schemeshard");
@@ -620,7 +608,7 @@ struct TSchemeShard::TTxCancelDataErasureShards : public TSchemeShard::TRwTxBase
620608
NIceDb::TNiceDb db(txc.DB);
621609
for (const auto& shard : DataErasureShards) {
622610
if (Self->DataErasureManager->Remove(shard)) {
623-
db.Table<Schema::WaitingDataErasureShards>().Key(shard.GetOwnerId(), shard.GetLocalId()).Update<Schema::WaitingDataErasureShards::Status>(EDataErasureStatus::COMPLETED);
611+
db.Table<Schema::WaitingDataErasureShards>().Key(shard.GetOwnerId(), shard.GetLocalId()).Delete();
624612
}
625613
}
626614
if (Self->DataErasureManager->GetStatus() == EDataErasureStatus::COMPLETED) {

ydb/core/tx/schemeshard/schemeshard_impl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,7 +2256,7 @@ void TSchemeShard::PersistRemoveSubDomain(NIceDb::TNiceDb& db, const TPathId& pa
22562256
}
22572257

22582258
if (DataErasureManager->Remove(pathId)) {
2259-
db.Table<Schema::WaitingDataErasureTenants>().Key(pathId.OwnerId, pathId.LocalPathId).Update<Schema::WaitingDataErasureTenants::Status>(EDataErasureStatus::COMPLETED);
2259+
db.Table<Schema::WaitingDataErasureTenants>().Key(pathId.OwnerId, pathId.LocalPathId).Delete();
22602260
}
22612261

22622262
db.Table<Schema::SubDomains>().Key(pathId.LocalPathId).Delete();
@@ -7094,7 +7094,7 @@ void TSchemeShard::SetPartitioning(TPathId pathId, TTableInfo::TPtr tableInfo, T
70947094
newPartitioningSet.reserve(newPartitioning.size());
70957095
const auto& oldPartitioning = tableInfo->GetPartitions();
70967096

7097-
std::vector<TShardIdx> dataErasureShards;
7097+
std::vector<TShardIdx> newDataErasureShards;
70987098
for (const auto& p: newPartitioning) {
70997099
if (!oldPartitioning.empty())
71007100
newPartitioningSet.insert(p.ShardIdx);
@@ -7104,11 +7104,11 @@ void TSchemeShard::SetPartitioning(TPathId pathId, TTableInfo::TPtr tableInfo, T
71047104
if (it != partitionStats.end()) {
71057105
EnqueueBackgroundCompaction(p.ShardIdx, it->second);
71067106
UpdateShardMetrics(p.ShardIdx, it->second);
7107-
dataErasureShards.push_back(p.ShardIdx);
7107+
newDataErasureShards.push_back(p.ShardIdx);
71087108
}
71097109
}
7110-
if (DataErasureManager->GetStatus() == EDataErasureStatus::IN_PROGRESS) {
7111-
Execute(CreateTxAddEntryToDataErasure(dataErasureShards), this->ActorContext());
7110+
if (EnableDataErasure && DataErasureManager->GetStatus() == EDataErasureStatus::IN_PROGRESS) {
7111+
Execute(CreateTxAddEntryToDataErasure(newDataErasureShards), this->ActorContext());
71127112
}
71137113

71147114
for (const auto& p: oldPartitioning) {

0 commit comments

Comments
 (0)