diff options
author | Ivan Nikolaev <[email protected]> | 2025-07-04 18:13:43 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2025-07-04 18:13:43 +0300 |
commit | 3170fe5f46a7d3d6d11961042ac2b831a8a7af6e (patch) | |
tree | 31b4ea93f2609081906981607546a37063671344 | |
parent | c5affc514c09d6e85352ca738693bdf42457ed8d (diff) |
LocalDB: rename DataCleanup to Vacuum (#19993)
-rw-r--r-- | ydb/core/keyvalue/keyvalue_flat_impl.h | 6 | ||||
-rw-r--r-- | ydb/core/tablet_flat/flat_executor.cpp | 34 | ||||
-rw-r--r-- | ydb/core/tablet_flat/flat_executor.h | 6 | ||||
-rw-r--r-- | ydb/core/tablet_flat/flat_executor_data_cleanup_logic.cpp | 206 | ||||
-rw-r--r-- | ydb/core/tablet_flat/flat_executor_ut.cpp | 4 | ||||
-rw-r--r-- | ydb/core/tablet_flat/flat_executor_vacuum_logic.cpp | 206 | ||||
-rw-r--r-- | ydb/core/tablet_flat/flat_executor_vacuum_logic.h (renamed from ydb/core/tablet_flat/flat_executor_data_cleanup_logic.h) | 20 | ||||
-rw-r--r-- | ydb/core/tablet_flat/tablet_flat_executor.cpp | 4 | ||||
-rw-r--r-- | ydb/core/tablet_flat/tablet_flat_executor.h | 4 | ||||
-rw-r--r-- | ydb/core/tablet_flat/test/libs/exec/dummy.h | 4 | ||||
-rw-r--r-- | ydb/core/tablet_flat/test/libs/exec/events.h | 4 | ||||
-rw-r--r-- | ydb/core/tablet_flat/ut/ut_vacuum.cpp (renamed from ydb/core/tablet_flat/ut/ut_data_cleanup.cpp) | 108 | ||||
-rw-r--r-- | ydb/core/tablet_flat/ut/ya.make | 2 | ||||
-rw-r--r-- | ydb/core/tablet_flat/ya.make | 2 | ||||
-rw-r--r-- | ydb/core/tx/datashard/datashard__data_cleanup.cpp | 4 | ||||
-rw-r--r-- | ydb/core/tx/datashard/datashard_impl.h | 2 |
16 files changed, 308 insertions, 308 deletions
diff --git a/ydb/core/keyvalue/keyvalue_flat_impl.h b/ydb/core/keyvalue/keyvalue_flat_impl.h index 78681a3df00..e63442bf215 100644 --- a/ydb/core/keyvalue/keyvalue_flat_impl.h +++ b/ydb/core/keyvalue/keyvalue_flat_impl.h @@ -566,7 +566,7 @@ protected: void Handle(TEvKeyValue::TEvForceTabletDataCleanup::TPtr &ev) { ALOG_DEBUG(NKikimrServices::KEYVALUE, "KeyValue# " << TabletID() << " Handle TEvForceTabletDataCleanup generation# " << ev->Get()->Generation); - Executor()->CleanupData(ev->Get()->Generation); + Executor()->StartVacuum(ev->Get()->Generation); } public: @@ -609,8 +609,8 @@ public: return false; } - void DataCleanupComplete(ui64 dataCleanupGeneration, const TActorContext &ctx) override { - STLOG(NLog::PRI_DEBUG, NKikimrServices::KEYVALUE_GC, KV271, "DataCleanupComplete", + void VacuumComplete(ui64 dataCleanupGeneration, const TActorContext &ctx) override { + STLOG(NLog::PRI_DEBUG, NKikimrServices::KEYVALUE_GC, KV271, "VacuumComplete", (TabletId, TabletID())); Execute(new TTxCompleteCleanupData(this, State.GetCleanupResetGeneration(), dataCleanupGeneration), ctx); } diff --git a/ydb/core/tablet_flat/flat_executor.cpp b/ydb/core/tablet_flat/flat_executor.cpp index 5892f5df7a1..159d47691ab 100644 --- a/ydb/core/tablet_flat/flat_executor.cpp +++ b/ydb/core/tablet_flat/flat_executor.cpp @@ -472,7 +472,7 @@ void TExecutor::Active(const TActorContext &ctx) { CompactionLogic = THolder<TCompactionLogic>(new TCompactionLogic(MemTableMemoryConsumersCollection.Get(), Logger.Get(), Broker.Get(), this, loadedState->Comp, Sprintf("tablet-%" PRIu64, Owner->TabletID()))); - DataCleanupLogic = MakeHolder<TDataCleanupLogic>(static_cast<NActors::IActorOps*>(this), this, Owner, Logger.Get(), GcLogic.Get()); + VacuumLogic = MakeHolder<TVacuumLogic>(static_cast<NActors::IActorOps*>(this), this, Owner, Logger.Get(), GcLogic.Get()); LogicRedo->InstallCounters(Counters.Get(), AppTxCounters); ResourceMetrics = MakeHolder<NMetrics::TResourceMetrics>(Owner->TabletID(), 0, Launcher); @@ -812,7 +812,7 @@ TExecutorCaches TExecutor::CleanupState() { Y_ENSURE(!LogicAlter); Y_ENSURE(!CompactionLogic); BorrowLogic.Destroy(); - DataCleanupLogic.Destroy(); + VacuumLogic.Destroy(); return caches; } @@ -996,7 +996,7 @@ void TExecutor::CheckCollectionBarrier(TIntrusivePtr<TBarrier> &barrier) { Owner->CompletedLoansChanged(OwnerCtx()); } } - if (DataCleanupLogic->NeedGC()) { + if (VacuumLogic->NeedGC()) { GcLogic->SendCollectGarbage(ActorContext()); } } @@ -1418,7 +1418,7 @@ void TExecutor::Handle(TEvTablet::TEvGcForStepAckResponse::TPtr &ev) { return; } - DataCleanupLogic->OnGcForStepAckResponse(Generation(), ev->Get()->Step, OwnerCtx()); + VacuumLogic->OnGcForStepAckResponse(Generation(), ev->Get()->Step, OwnerCtx()); } void TExecutor::AdvancePendingPartSwitches() { @@ -1433,8 +1433,8 @@ void TExecutor::AdvancePendingPartSwitches() { PlanTransactionActivation(); MaybeRelaxRejectProbability(); - // Note: followers don't have DataCleanupLogic - if (NeedFollowerSnapshot || DataCleanupLogic && DataCleanupLogic->NeedLogSnaphot()) { + // Note: followers don't have VacuumLogic + if (NeedFollowerSnapshot || VacuumLogic && VacuumLogic->NeedLogSnaphot()) { MakeLogSnapshot(); } } @@ -2872,7 +2872,7 @@ void TExecutor::MakeLogSnapshot() { BorrowLogic->SnapToLog(snap, *commit); GcLogic->SnapToLog(snap, commit->Step); LogicSnap->MakeSnap(snap, *commit, Logger.Get()); - DataCleanupLogic->OnMakeLogSnapshot(Generation(), commit->Step); + VacuumLogic->OnMakeLogSnapshot(Generation(), commit->Step); AttachLeaseCommit(commit.Get(), /* force */ true); CommitManager->Commit(commit); @@ -3187,8 +3187,8 @@ void TExecutor::Handle(TEvTablet::TEvCommitResult::TPtr &ev, const TActorContext case ECommit::Snap: LogicSnap->Confirm(msg->Step); - DataCleanupLogic->OnSnapshotCommited(Generation(), step); - if (NeedFollowerSnapshot || DataCleanupLogic->NeedLogSnaphot()) + VacuumLogic->OnSnapshotCommited(Generation(), step); + if (NeedFollowerSnapshot || VacuumLogic->NeedLogSnaphot()) MakeLogSnapshot(); break; @@ -3227,7 +3227,7 @@ void TExecutor::Handle(TEvBlobStorage::TEvCollectGarbageResult::TPtr &ev) { if (auto retryDelay = GcLogic->OnCollectGarbageResult(ev)) { Schedule(retryDelay, new TEvPrivate::TEvRetryGcRequest(ev->Get()->Channel)); } - DataCleanupLogic->OnCollectedGarbage(OwnerCtx()); + VacuumLogic->OnCollectedGarbage(OwnerCtx()); } void TExecutor::Handle(TEvPrivate::TEvRetryGcRequest::TPtr &ev, const TActorContext &ctx) { @@ -3747,7 +3747,7 @@ void TExecutor::Handle(NOps::TEvResult *ops, TProdCompact *msg, bool cancelled) Y_ENSURE(InFlyCompactionGcBarriers.emplace(commit->Step, ops->Barrier).second); - DataCleanupLogic->OnCompleteCompaction(tableId, CompactionLogic->GetFinishedCompactionInfo(tableId)); + VacuumLogic->OnCompleteCompaction(tableId, CompactionLogic->GetFinishedCompactionInfo(tableId)); AttachLeaseCommit(commit.Get()); CommitManager->Commit(commit); @@ -3780,7 +3780,7 @@ void TExecutor::Handle(NOps::TEvResult *ops, TProdCompact *msg, bool cancelled) activeTransaction.Done(); - if (LogicSnap->MayFlush(false) || DataCleanupLogic->NeedLogSnaphot()) { + if (LogicSnap->MayFlush(false) || VacuumLogic->NeedLogSnaphot()) { MakeLogSnapshot(); } } @@ -4143,14 +4143,14 @@ bool TExecutor::CompactTables() { } } -void TExecutor::CleanupData(ui64 dataCleanupGeneration) { - if (DataCleanupLogic->TryStartCleanup(dataCleanupGeneration, OwnerCtx())) { +void TExecutor::StartVacuum(ui64 vacuumGeneration) { + if (VacuumLogic->TryStartVacuum(vacuumGeneration, OwnerCtx())) { for (const auto& [tableId, _] : Scheme().Tables) { auto compactionId = CompactionLogic->PrepareForceCompaction(tableId); - DataCleanupLogic->OnCompactionPrepared(tableId, compactionId); + VacuumLogic->OnCompactionPrepared(tableId, compactionId); } - DataCleanupLogic->WaitCompaction(); - if (DataCleanupLogic->NeedLogSnaphot()) { + VacuumLogic->WaitCompaction(); + if (VacuumLogic->NeedLogSnaphot()) { MakeLogSnapshot(); } } diff --git a/ydb/core/tablet_flat/flat_executor.h b/ydb/core/tablet_flat/flat_executor.h index a0f99f85626..5e4246fa414 100644 --- a/ydb/core/tablet_flat/flat_executor.h +++ b/ydb/core/tablet_flat/flat_executor.h @@ -14,8 +14,8 @@ #include "flat_exec_commit.h" #include "flat_executor_misc.h" #include "flat_executor_compaction_logic.h" -#include "flat_executor_data_cleanup_logic.h" #include "flat_executor_gclogic.h" +#include "flat_executor_vacuum_logic.h" #include "flat_bio_events.h" #include "flat_bio_stats.h" #include "flat_fwd_sieve.h" @@ -467,7 +467,7 @@ class TExecutor THolder<TExecutorGCLogic> GcLogic; THolder<TCompactionLogic> CompactionLogic; THolder<TExecutorBorrowLogic> BorrowLogic; - THolder<TDataCleanupLogic> DataCleanupLogic; + THolder<TVacuumLogic> VacuumLogic; TLoadBlobQueue PendingBlobQueue; @@ -683,7 +683,7 @@ public: ui64 CompactTable(ui32 tableId) override; bool CompactTables() override; - void CleanupData(ui64 dataCleanupGeneration) override; + void StartVacuum(ui64 vacuumGeneration) override; void Handle(NMemory::TEvMemTableRegistered::TPtr &ev); void Handle(NMemory::TEvMemTableCompact::TPtr &ev); diff --git a/ydb/core/tablet_flat/flat_executor_data_cleanup_logic.cpp b/ydb/core/tablet_flat/flat_executor_data_cleanup_logic.cpp deleted file mode 100644 index 8e3d4cd1dc8..00000000000 --- a/ydb/core/tablet_flat/flat_executor_data_cleanup_logic.cpp +++ /dev/null @@ -1,206 +0,0 @@ -#include "flat_executor_data_cleanup_logic.h" - -namespace NKikimr::NTabletFlatExecutor { - -TDataCleanupLogic::TDataCleanupLogic(IOps* ops, IExecutor* executor, ITablet* owner, NUtil::ILogger* logger, TExecutorGCLogic* gcLogic) - : Ops(ops) - , Executor(executor) - , Owner(owner) - , Logger(logger) - , GcLogic(gcLogic) -{} - -bool TDataCleanupLogic::TryStartCleanup(ui64 dataCleanupGeneration, const TActorContext& ctx) { - switch (State) { - case EDataCleanupState::Idle: { - if (CurrentDataCleanupGeneration >= dataCleanupGeneration) { - if (auto logl = Logger->Log(ELnLev::Info)) { - logl << "TDataCleanupLogic: DataCleanup for tablet with id " << Owner->TabletID() - << " had already completed for generation " << dataCleanupGeneration - << ", current DataCleanup generation: " << CurrentDataCleanupGeneration; - } - // repeat DataCleanupComplete callback - CompleteDataCleanup(ctx); - return false; - } else { - CurrentDataCleanupGeneration = dataCleanupGeneration; - if (auto logl = Logger->Log(ELnLev::Info)) { - logl << "TDataCleanupLogic: Starting DataCleanup for tablet with id " << Owner->TabletID() - << ", current DataCleanup generation: " << CurrentDataCleanupGeneration; - } - State = EDataCleanupState::PendingCompaction; - return true; - } - break; - } - default: { // DataCleanup in progress - if (dataCleanupGeneration > CurrentDataCleanupGeneration) { - NextDataCleanupGeneration = Max(dataCleanupGeneration, NextDataCleanupGeneration); - if (auto logl = Logger->Log(ELnLev::Info)) { - logl << "TDataCleanupLogic: schedule next DataCleanup for tablet with id " << Owner->TabletID() - << ", current DataCleanup generation: " << CurrentDataCleanupGeneration - << ", next DataCleanup generation: " << NextDataCleanupGeneration; - } - return false; - } else { - // more recent DataCleanup in progress, so just ignore osolete generation - return false; - } - } - } -} - -void TDataCleanupLogic::OnCompactionPrepared(ui32 tableId, ui64 compactionId) { - Y_ENSURE(State == EDataCleanupState::PendingCompaction); - CompactingTables[tableId] = {tableId, compactionId}; -} - -void TDataCleanupLogic::WaitCompaction() { - Y_ENSURE(State == EDataCleanupState::PendingCompaction); - if (CompactingTables.empty()) { - State = EDataCleanupState::PendingFirstSnapshot; - } else { - State = EDataCleanupState::WaitCompaction; - } -} - -void TDataCleanupLogic::OnCompleteCompaction( - ui32 tableId, - const TFinishedCompactionInfo& finishedCompactionInfo) -{ - if (State != EDataCleanupState::WaitCompaction) { - return; - } - - if (auto it = CompactingTables.find(tableId); it != CompactingTables.end()) { - if (finishedCompactionInfo.Edge >= it->second.CompactionId) { - CompactingTables.erase(it); - } - } - if (CompactingTables.empty()) { - State = EDataCleanupState::PendingFirstSnapshot; - } -} - -bool TDataCleanupLogic::NeedLogSnaphot() { - switch (State) { - case EDataCleanupState::PendingFirstSnapshot: - case EDataCleanupState::PendingSecondSnapshot: - return true; - default: - return false; - } -} - -void TDataCleanupLogic::OnMakeLogSnapshot(ui32 generation, ui32 step) { - switch (State) { - case EDataCleanupState::PendingFirstSnapshot: { - FirstLogSnaphotStep = TGCTime(generation, step); - State = EDataCleanupState::WaitFirstSnapshot; - break; - } - case EDataCleanupState::PendingSecondSnapshot: { - SecondLogSnaphotStep = TGCTime(generation, step); - State = EDataCleanupState::WaitSecondSnapshot; - break; - } - default: { - break; - } - } -} - -void TDataCleanupLogic::OnSnapshotCommited(ui32 generation, ui32 step) { - switch (State) { - case EDataCleanupState::WaitFirstSnapshot: { - if (FirstLogSnaphotStep <= TGCTime(generation, step)) { - State = EDataCleanupState::PendingSecondSnapshot; - } - break; - } - case EDataCleanupState::WaitSecondSnapshot: { - if (SecondLogSnaphotStep <= TGCTime(generation, step)) { - Ops->Send(Owner->Tablet(), new TEvTablet::TEvGcForStepAckRequest(FirstLogSnaphotStep.Generation, FirstLogSnaphotStep.Step)); - if (GcLogic->HasGarbageBefore(FirstLogSnaphotStep)) { - State = EDataCleanupState::WaitAllGCs; - } else { - State = EDataCleanupState::WaitLogGC; - } - } - break; - } - default: { - break; - } - } -} - -void TDataCleanupLogic::OnCollectedGarbage(const TActorContext& ctx) { - switch (State) { - case EDataCleanupState::WaitAllGCs: { - if (!GcLogic->HasGarbageBefore(FirstLogSnaphotStep)) { - State = EDataCleanupState::WaitLogGC; - } - break; - } - case EDataCleanupState::WaitTabletGC: { - if (!GcLogic->HasGarbageBefore(FirstLogSnaphotStep)) { - CompleteDataCleanup(ctx); - } - break; - } - default: { - break; - } - } -} - -void TDataCleanupLogic::OnGcForStepAckResponse(ui32 generation, ui32 step, const TActorContext& ctx) { - switch (State) { - case EDataCleanupState::WaitAllGCs: { - if (FirstLogSnaphotStep <= TGCTime(generation, step)) { - State = EDataCleanupState::WaitTabletGC; - } - break; - } - case EDataCleanupState::WaitLogGC: { - if (FirstLogSnaphotStep <= TGCTime(generation, step)) { - CompleteDataCleanup(ctx); - } - break; - } - default: { - break; - } - } -} - -bool TDataCleanupLogic::NeedGC() { - switch (State) { - case EDataCleanupState::PendingSecondSnapshot: - case EDataCleanupState::WaitSecondSnapshot: - case EDataCleanupState::WaitAllGCs: - case EDataCleanupState::WaitTabletGC: { - return GcLogic->HasGarbageBefore(FirstLogSnaphotStep); - } - default: { - return false; - } - } -} - -void TDataCleanupLogic::CompleteDataCleanup(const TActorContext& ctx) { - State = EDataCleanupState::Idle; - if (NextDataCleanupGeneration) { - Executor->CleanupData(std::exchange(NextDataCleanupGeneration, 0)); - } else { - // report complete only if all planned cleanups completed - Owner->DataCleanupComplete(CurrentDataCleanupGeneration, ctx); - if (auto logl = Logger->Log(ELnLev::Info)) { - logl << "TDataCleanupLogic: DataCleanup finished for tablet with id " << Owner->TabletID() - << ", current DataCleanup generation: " << CurrentDataCleanupGeneration; - } - } -} - -} // namespace NKikimr::NTabletFlatExecutor diff --git a/ydb/core/tablet_flat/flat_executor_ut.cpp b/ydb/core/tablet_flat/flat_executor_ut.cpp index 81a963af441..e6bcd4af329 100644 --- a/ydb/core/tablet_flat/flat_executor_ut.cpp +++ b/ydb/core/tablet_flat/flat_executor_ut.cpp @@ -447,8 +447,8 @@ class TTestFlatTablet : public TActor<TTestFlatTablet>, public TTabletExecutedFl Send(Sender, new NFake::TEvCompacted(table)); } - void DataCleanupComplete(ui64 dataCleanupComplete, const TActorContext&) override { - Send(Sender, new NFake::TEvDataCleaned(dataCleanupComplete)); + void VacuumComplete(ui64 vacuumComplete, const TActorContext&) override { + Send(Sender, new NFake::TEvDataCleaned(vacuumComplete)); } void ScanComplete(NTable::EStatus, TAutoPtr<IDestructable>, ui64 cookie, const TActorContext&) override diff --git a/ydb/core/tablet_flat/flat_executor_vacuum_logic.cpp b/ydb/core/tablet_flat/flat_executor_vacuum_logic.cpp new file mode 100644 index 00000000000..c2e5d5ad1c7 --- /dev/null +++ b/ydb/core/tablet_flat/flat_executor_vacuum_logic.cpp @@ -0,0 +1,206 @@ +#include "flat_executor_vacuum_logic.h" + +namespace NKikimr::NTabletFlatExecutor { + +TVacuumLogic::TVacuumLogic(IOps* ops, IExecutor* executor, ITablet* owner, NUtil::ILogger* logger, TExecutorGCLogic* gcLogic) + : Ops(ops) + , Executor(executor) + , Owner(owner) + , Logger(logger) + , GcLogic(gcLogic) +{} + +bool TVacuumLogic::TryStartVacuum(ui64 vacuumGeneration, const TActorContext& ctx) { + switch (State) { + case EVacuumState::Idle: { + if (CurrentVacuumGeneration >= vacuumGeneration) { + if (auto logl = Logger->Log(ELnLev::Info)) { + logl << "TVacuumLogic: Vacuum for tablet with id " << Owner->TabletID() + << " had already completed for generation " << vacuumGeneration + << ", current Vacuum generation: " << CurrentVacuumGeneration; + } + // repeat VacuumComplete callback + CompleteVacuum(ctx); + return false; + } else { + CurrentVacuumGeneration = vacuumGeneration; + if (auto logl = Logger->Log(ELnLev::Info)) { + logl << "TVacuumLogic: Starting Vacuum for tablet with id " << Owner->TabletID() + << ", current Vacuum generation: " << CurrentVacuumGeneration; + } + State = EVacuumState::PendingCompaction; + return true; + } + break; + } + default: { // Vacuum in progress + if (vacuumGeneration > CurrentVacuumGeneration) { + NextVacuumGeneration = Max(vacuumGeneration, NextVacuumGeneration); + if (auto logl = Logger->Log(ELnLev::Info)) { + logl << "TVacuumLogic: schedule next Vacuum for tablet with id " << Owner->TabletID() + << ", current Vacuum generation: " << CurrentVacuumGeneration + << ", next Vacuum generation: " << NextVacuumGeneration; + } + return false; + } else { + // more recent Vacuum in progress, so just ignore osolete generation + return false; + } + } + } +} + +void TVacuumLogic::OnCompactionPrepared(ui32 tableId, ui64 compactionId) { + Y_ENSURE(State == EVacuumState::PendingCompaction); + CompactingTables[tableId] = {tableId, compactionId}; +} + +void TVacuumLogic::WaitCompaction() { + Y_ENSURE(State == EVacuumState::PendingCompaction); + if (CompactingTables.empty()) { + State = EVacuumState::PendingFirstSnapshot; + } else { + State = EVacuumState::WaitCompaction; + } +} + +void TVacuumLogic::OnCompleteCompaction( + ui32 tableId, + const TFinishedCompactionInfo& finishedCompactionInfo) +{ + if (State != EVacuumState::WaitCompaction) { + return; + } + + if (auto it = CompactingTables.find(tableId); it != CompactingTables.end()) { + if (finishedCompactionInfo.Edge >= it->second.CompactionId) { + CompactingTables.erase(it); + } + } + if (CompactingTables.empty()) { + State = EVacuumState::PendingFirstSnapshot; + } +} + +bool TVacuumLogic::NeedLogSnaphot() { + switch (State) { + case EVacuumState::PendingFirstSnapshot: + case EVacuumState::PendingSecondSnapshot: + return true; + default: + return false; + } +} + +void TVacuumLogic::OnMakeLogSnapshot(ui32 generation, ui32 step) { + switch (State) { + case EVacuumState::PendingFirstSnapshot: { + FirstLogSnaphotStep = TGCTime(generation, step); + State = EVacuumState::WaitFirstSnapshot; + break; + } + case EVacuumState::PendingSecondSnapshot: { + SecondLogSnaphotStep = TGCTime(generation, step); + State = EVacuumState::WaitSecondSnapshot; + break; + } + default: { + break; + } + } +} + +void TVacuumLogic::OnSnapshotCommited(ui32 generation, ui32 step) { + switch (State) { + case EVacuumState::WaitFirstSnapshot: { + if (FirstLogSnaphotStep <= TGCTime(generation, step)) { + State = EVacuumState::PendingSecondSnapshot; + } + break; + } + case EVacuumState::WaitSecondSnapshot: { + if (SecondLogSnaphotStep <= TGCTime(generation, step)) { + Ops->Send(Owner->Tablet(), new TEvTablet::TEvGcForStepAckRequest(FirstLogSnaphotStep.Generation, FirstLogSnaphotStep.Step)); + if (GcLogic->HasGarbageBefore(FirstLogSnaphotStep)) { + State = EVacuumState::WaitAllGCs; + } else { + State = EVacuumState::WaitLogGC; + } + } + break; + } + default: { + break; + } + } +} + +void TVacuumLogic::OnCollectedGarbage(const TActorContext& ctx) { + switch (State) { + case EVacuumState::WaitAllGCs: { + if (!GcLogic->HasGarbageBefore(FirstLogSnaphotStep)) { + State = EVacuumState::WaitLogGC; + } + break; + } + case EVacuumState::WaitTabletGC: { + if (!GcLogic->HasGarbageBefore(FirstLogSnaphotStep)) { + CompleteVacuum(ctx); + } + break; + } + default: { + break; + } + } +} + +void TVacuumLogic::OnGcForStepAckResponse(ui32 generation, ui32 step, const TActorContext& ctx) { + switch (State) { + case EVacuumState::WaitAllGCs: { + if (FirstLogSnaphotStep <= TGCTime(generation, step)) { + State = EVacuumState::WaitTabletGC; + } + break; + } + case EVacuumState::WaitLogGC: { + if (FirstLogSnaphotStep <= TGCTime(generation, step)) { + CompleteVacuum(ctx); + } + break; + } + default: { + break; + } + } +} + +bool TVacuumLogic::NeedGC() { + switch (State) { + case EVacuumState::PendingSecondSnapshot: + case EVacuumState::WaitSecondSnapshot: + case EVacuumState::WaitAllGCs: + case EVacuumState::WaitTabletGC: { + return GcLogic->HasGarbageBefore(FirstLogSnaphotStep); + } + default: { + return false; + } + } +} + +void TVacuumLogic::CompleteVacuum(const TActorContext& ctx) { + State = EVacuumState::Idle; + if (NextVacuumGeneration) { + Executor->StartVacuum(std::exchange(NextVacuumGeneration, 0)); + } else { + // report complete only if all planned cleanups completed + Owner->VacuumComplete(CurrentVacuumGeneration, ctx); + if (auto logl = Logger->Log(ELnLev::Info)) { + logl << "TVacuumLogic: Vacuum finished for tablet with id " << Owner->TabletID() + << ", current Vacuum generation: " << CurrentVacuumGeneration; + } + } +} + +} // namespace NKikimr::NTabletFlatExecutor diff --git a/ydb/core/tablet_flat/flat_executor_data_cleanup_logic.h b/ydb/core/tablet_flat/flat_executor_vacuum_logic.h index ec2be028121..06ab339285b 100644 --- a/ydb/core/tablet_flat/flat_executor_data_cleanup_logic.h +++ b/ydb/core/tablet_flat/flat_executor_vacuum_logic.h @@ -6,8 +6,8 @@ namespace NKikimr::NTabletFlatExecutor { -class TDataCleanupLogic { - enum class EDataCleanupState { +class TVacuumLogic { + enum class EVacuumState { Idle, PendingCompaction, WaitCompaction, @@ -20,7 +20,7 @@ class TDataCleanupLogic { WaitLogGC, }; - struct TCleanupTableInfo { + struct TVacuumTableInfo { ui32 TableId = Max<ui32>(); ui64 CompactionId = 0; }; @@ -31,9 +31,9 @@ public: using ITablet = NFlatExecutorSetup::ITablet; using ELnLev = NUtil::ELnLev; - TDataCleanupLogic(IOps* ops, IExecutor* executor, ITablet* owner, NUtil::ILogger* logger, TExecutorGCLogic* gcLogic); + TVacuumLogic(IOps* ops, IExecutor* executor, ITablet* owner, NUtil::ILogger* logger, TExecutorGCLogic* gcLogic); - bool TryStartCleanup(ui64 dataCleanupGeneration, const TActorContext& ctx); + bool TryStartVacuum(ui64 vacuumGeneration, const TActorContext& ctx); void OnCompactionPrepared(ui32 tableId, ui64 compactionId); void WaitCompaction(); void OnCompleteCompaction(ui32 tableId, const TFinishedCompactionInfo& finishedCompactionInfo); @@ -45,7 +45,7 @@ public: bool NeedGC(); private: - void CompleteDataCleanup(const TActorContext& ctx); + void CompleteVacuum(const TActorContext& ctx); private: IOps* Ops; @@ -54,10 +54,10 @@ private: NUtil::ILogger* const Logger; TExecutorGCLogic* const GcLogic; - ui64 CurrentDataCleanupGeneration = 0; - ui64 NextDataCleanupGeneration = 0; - EDataCleanupState State = EDataCleanupState::Idle; - THashMap<ui32, TCleanupTableInfo> CompactingTables; // tracks statuses of compaction + ui64 CurrentVacuumGeneration = 0; + ui64 NextVacuumGeneration = 0; + EVacuumState State = EVacuumState::Idle; + THashMap<ui32, TVacuumTableInfo> CompactingTables; // tracks statuses of compaction // two subsequent are snapshots required to force GC TGCTime FirstLogSnaphotStep; diff --git a/ydb/core/tablet_flat/tablet_flat_executor.cpp b/ydb/core/tablet_flat/tablet_flat_executor.cpp index e051cb17c9d..4651e12abdd 100644 --- a/ydb/core/tablet_flat/tablet_flat_executor.cpp +++ b/ydb/core/tablet_flat/tablet_flat_executor.cpp @@ -21,8 +21,8 @@ namespace NFlatExecutorSetup { Y_UNUSED(ctx); } - void ITablet::DataCleanupComplete(ui64 dataCleanupGeneration, const TActorContext& ctx) { - Y_UNUSED(dataCleanupGeneration); + void ITablet::VacuumComplete(ui64 vacuumGeneration, const TActorContext& ctx) { + Y_UNUSED(vacuumGeneration); Y_UNUSED(ctx); } diff --git a/ydb/core/tablet_flat/tablet_flat_executor.h b/ydb/core/tablet_flat/tablet_flat_executor.h index a8650a2c0ee..a091f263dbe 100644 --- a/ydb/core/tablet_flat/tablet_flat_executor.h +++ b/ydb/core/tablet_flat/tablet_flat_executor.h @@ -500,7 +500,7 @@ namespace NFlatExecutorSetup { virtual void SnapshotComplete(TIntrusivePtr<TTableSnapshotContext> snapContext, const TActorContext &ctx); // would be FAIL in default implementation virtual void CompletedLoansChanged(const TActorContext &ctx); // would be no-op in default implementation virtual void CompactionComplete(ui32 tableId, const TActorContext &ctx); // would be no-op in default implementation - virtual void DataCleanupComplete(ui64 dataCleanupGeneration, const TActorContext& ctx); + virtual void VacuumComplete(ui64 vacuumGeneration, const TActorContext& ctx); virtual void ScanComplete(NTable::EStatus status, TAutoPtr<IDestructable> prod, ui64 cookie, const TActorContext &ctx); @@ -654,7 +654,7 @@ namespace NFlatExecutorSetup { virtual void SetPreloadTablesData(THashSet<ui32> tables) = 0; - virtual void CleanupData(ui64 dataCleanupGeneration) = 0; + virtual void StartVacuum(ui64 vacuumGeneration) = 0; ui32 Generation() const { return Generation0; } ui32 Step() const { return Step0; } diff --git a/ydb/core/tablet_flat/test/libs/exec/dummy.h b/ydb/core/tablet_flat/test/libs/exec/dummy.h index 769acfb4d8d..aabdb46767f 100644 --- a/ydb/core/tablet_flat/test/libs/exec/dummy.h +++ b/ydb/core/tablet_flat/test/libs/exec/dummy.h @@ -128,10 +128,10 @@ namespace NFake { Send(Owner, new NFake::TEvCompacted(table)); } - void DataCleanupComplete(ui64 dataCleanupGeneration, const TActorContext&) override + void VacuumComplete(ui64 vacuumGeneration, const TActorContext&) override { if (Flags & ui32(EFlg::Clean)) - Send(Owner, new NFake::TEvDataCleaned(dataCleanupGeneration)); + Send(Owner, new NFake::TEvDataCleaned(vacuumGeneration)); } void SnapshotComplete( diff --git a/ydb/core/tablet_flat/test/libs/exec/events.h b/ydb/core/tablet_flat/test/libs/exec/events.h index 37e6f25a4cb..39921bd9a89 100644 --- a/ydb/core/tablet_flat/test/libs/exec/events.h +++ b/ydb/core/tablet_flat/test/libs/exec/events.h @@ -91,9 +91,9 @@ namespace NFake { }; struct TEvDataCleaned : public TEventLocal<TEvDataCleaned, EvDataCleaned> { - TEvDataCleaned(ui64 dataCleanupGeneration) : DataCleanupGeneration(dataCleanupGeneration) { } + TEvDataCleaned(ui64 vacuumGeneration) : VacuumGeneration(vacuumGeneration) { } - ui64 DataCleanupGeneration; + ui64 VacuumGeneration; }; struct TEvCompact : public TEventLocal<TEvCompact, EvCompact> { diff --git a/ydb/core/tablet_flat/ut/ut_data_cleanup.cpp b/ydb/core/tablet_flat/ut/ut_vacuum.cpp index af906f457a4..f145d1b6cc5 100644 --- a/ydb/core/tablet_flat/ut/ut_data_cleanup.cpp +++ b/ydb/core/tablet_flat/ut/ut_vacuum.cpp @@ -192,44 +192,44 @@ int BlobStorageValueCountInAllGroups(TMyEnvBase& env, const TString& value) { return count; } -Y_UNIT_TEST_SUITE(DataCleanup) { +Y_UNIT_TEST_SUITE(Vacuum) { ui32 TestTabletFlags = ui32(NFake::TDummy::EFlg::Comp) | ui32(NFake::TDummy::EFlg::Clean); - Y_UNIT_TEST(CleanupDataNoTables) { + Y_UNIT_TEST(StartVacuumNoTables) { TMyEnvBase env; env.FireDummyTablet(TestTabletFlags); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(234); + executor->StartVacuum(234); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); auto ev = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev->Get()->DataCleanupGeneration, 234); + UNIT_ASSERT_VALUES_EQUAL(ev->Get()->VacuumGeneration, 234); } - Y_UNIT_TEST(CleanupDataNoTablesWithRestart) { + Y_UNIT_TEST(StartVacuumNoTablesWithRestart) { TMyEnvBase env; env.FireDummyTablet(TestTabletFlags); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(234); + executor->StartVacuum(234); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); auto ev1 = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev1->Get()->DataCleanupGeneration, 234); + UNIT_ASSERT_VALUES_EQUAL(ev1->Get()->VacuumGeneration, 234); env.RestartTablet(TestTabletFlags); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(235); + executor->StartVacuum(235); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }, true); auto ev2 = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->DataCleanupGeneration, 235); + UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->VacuumGeneration, 235); } - Y_UNIT_TEST(CleanupDataLog) { + Y_UNIT_TEST(StartVacuumLog) { TMyEnvBase env; env.FireDummyTablet(TestTabletFlags); env.SendSync(new NFake::TEvExecute{ new TTxInitSchema({ 101 }, true) }); @@ -252,17 +252,17 @@ Y_UNIT_TEST_SUITE(DataCleanup) { UNIT_ASSERT_EQUAL(readRows, 0); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(234); + executor->StartVacuum(234); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); auto ev = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev->Get()->DataCleanupGeneration, 234); + UNIT_ASSERT_VALUES_EQUAL(ev->Get()->VacuumGeneration, 234); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, "Some_value"), 0); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, "Some_other_value"), 0); } - Y_UNIT_TEST(CleanupData) { + Y_UNIT_TEST(StartVacuum) { TString value42(size_t(100 * 1024), 'a'); TMyEnvBase env; @@ -282,16 +282,16 @@ Y_UNIT_TEST_SUITE(DataCleanup) { UNIT_ASSERT_VALUES_EQUAL(readRows, 0); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(234); + executor->StartVacuum(234); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); auto ev = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev->Get()->DataCleanupGeneration, 234); + UNIT_ASSERT_VALUES_EQUAL(ev->Get()->VacuumGeneration, 234); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value42), 0); } - Y_UNIT_TEST(CleanupDataMultipleFamilies) { + Y_UNIT_TEST(StartVacuumMultipleFamilies) { TString value42(size_t(100 * 1024), 'a'); TString value43(size_t(100 * 1024), 'b'); TString value44(size_t(100 * 1024), 'c'); @@ -319,11 +319,11 @@ Y_UNIT_TEST_SUITE(DataCleanup) { UNIT_ASSERT_VALUES_EQUAL(readRows, 2); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(234); + executor->StartVacuum(234); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); auto ev1 = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev1->Get()->DataCleanupGeneration, 234); + UNIT_ASSERT_VALUES_EQUAL(ev1->Get()->VacuumGeneration, 234); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCount(env, value42, 1), 1); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCount(env, value43, 2), 1); @@ -353,7 +353,7 @@ Y_UNIT_TEST_SUITE(DataCleanup) { env.WaitFor<NFake::TEvCompacted>(); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(235); + executor->StartVacuum(235); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); @@ -364,14 +364,14 @@ Y_UNIT_TEST_SUITE(DataCleanup) { gcEvents.Stop().Unblock(); auto ev2 = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->DataCleanupGeneration, 235); + UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->VacuumGeneration, 235); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value42), 0); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value43), 0); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value44), 0); } - Y_UNIT_TEST(CleanupDataMultipleTables) { + Y_UNIT_TEST(StartVacuumMultipleTables) { TString value42(size_t(100 * 1024), 'a'); TString value43(size_t(100 * 1024), 'b'); TString value44(size_t(100 * 1024), 'c'); @@ -407,18 +407,18 @@ Y_UNIT_TEST_SUITE(DataCleanup) { UNIT_ASSERT_EQUAL(readRows, 0); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(234); + executor->StartVacuum(234); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); auto ev = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev->Get()->DataCleanupGeneration, 234); + UNIT_ASSERT_VALUES_EQUAL(ev->Get()->VacuumGeneration, 234); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value42), 0); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value43), 0); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value44), 0); } - Y_UNIT_TEST(CleanupDataWithFollowers) { + Y_UNIT_TEST(StartVacuumWithFollowers) { TString value41(size_t(100 * 1024), 'a'); TString value42(size_t(100 * 1024), 'b'); TString value43(size_t(100 * 1024), 'c'); @@ -450,18 +450,18 @@ Y_UNIT_TEST_SUITE(DataCleanup) { UNIT_ASSERT_EQUAL(readRows, 0); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(234); + executor->StartVacuum(234); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); auto ev = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev->Get()->DataCleanupGeneration, 234); + UNIT_ASSERT_VALUES_EQUAL(ev->Get()->VacuumGeneration, 234); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value41), 0); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value42), 0); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value43), 0); } - Y_UNIT_TEST(CleanupDataMultipleTimes) { + Y_UNIT_TEST(StartVacuumMultipleTimes) { TString value42(size_t(100 * 1024), 'b'); TString value43(size_t(90 * 1024), 'f'); @@ -482,12 +482,12 @@ Y_UNIT_TEST_SUITE(DataCleanup) { UNIT_ASSERT_EQUAL(readRows, 0); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(234); - executor->CleanupData(235); + executor->StartVacuum(234); + executor->StartVacuum(235); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); auto ev1 = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev1->Get()->DataCleanupGeneration, 235); // only last genration should be present + UNIT_ASSERT_VALUES_EQUAL(ev1->Get()->VacuumGeneration, 235); // only last genration should be present env.SendSync(new NFake::TEvExecute{ new TTxWriteRow(101, 43, value43) }); @@ -501,23 +501,23 @@ Y_UNIT_TEST_SUITE(DataCleanup) { UNIT_ASSERT_EQUAL(readRows, 0); env.SendAsync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(236); + executor->StartVacuum(236); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); env.SendAsync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(237); + executor->StartVacuum(237); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); auto ev2 = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->DataCleanupGeneration, 237); // only last genration should be present + UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->VacuumGeneration, 237); // only last genration should be present UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value42), 0); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value43), 0); } - Y_UNIT_TEST(CleanupDataEmptyTable) { + Y_UNIT_TEST(StartVacuumEmptyTable) { TMyEnvBase env; env.FireDummyTablet(TestTabletFlags); env.SendSync(new NFake::TEvExecute{ new TTxInitSchema({ 101 }) }); @@ -527,15 +527,15 @@ Y_UNIT_TEST_SUITE(DataCleanup) { UNIT_ASSERT_EQUAL(readRows, 0); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(234); + executor->StartVacuum(234); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); auto ev = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev->Get()->DataCleanupGeneration, 234); + UNIT_ASSERT_VALUES_EQUAL(ev->Get()->VacuumGeneration, 234); } - Y_UNIT_TEST(CleanupDataWithRestarts) { + Y_UNIT_TEST(StartVacuumWithRestarts) { TString value42(size_t(100 * 1024), 'a'); TString value43(size_t(100 * 1024), 'b'); @@ -556,11 +556,11 @@ Y_UNIT_TEST_SUITE(DataCleanup) { env.SendSync(new NFake::TEvExecute{ new TTxDeleteRow(101, 43) }, true); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(234); + executor->StartVacuum(234); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); auto ev1 = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev1->Get()->DataCleanupGeneration, 234); + UNIT_ASSERT_VALUES_EQUAL(ev1->Get()->VacuumGeneration, 234); env.RestartTablet(TestTabletFlags); @@ -582,7 +582,7 @@ Y_UNIT_TEST_SUITE(DataCleanup) { env.WaitFor<NFake::TEvCompacted>(); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(235); + executor->StartVacuum(235); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); @@ -593,13 +593,13 @@ Y_UNIT_TEST_SUITE(DataCleanup) { gcEvents.Stop().Unblock(); auto ev2 = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->DataCleanupGeneration, 235); + UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->VacuumGeneration, 235); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value42), 0); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value43), 0); } - Y_UNIT_TEST(CleanupDataRetryWithNotGreaterGenerations) { + Y_UNIT_TEST(StartVacuumRetryWithNotGreaterGenerations) { TString value42(size_t(100 * 1024), 'a'); TMyEnvBase env; @@ -619,30 +619,30 @@ Y_UNIT_TEST_SUITE(DataCleanup) { UNIT_ASSERT_VALUES_EQUAL(readRows, 0); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(234); + executor->StartVacuum(234); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); auto ev1 = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev1->Get()->DataCleanupGeneration, 234); + UNIT_ASSERT_VALUES_EQUAL(ev1->Get()->VacuumGeneration, 234); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(115); + executor->StartVacuum(115); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); auto ev2 = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->DataCleanupGeneration, 234); + UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->VacuumGeneration, 234); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(234); + executor->StartVacuum(234); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); auto ev3 = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev3->Get()->DataCleanupGeneration, 234); + UNIT_ASSERT_VALUES_EQUAL(ev3->Get()->VacuumGeneration, 234); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value42), 0); } - Y_UNIT_TEST(CleanupDataWithTabletGCErrors) { + Y_UNIT_TEST(StartVacuumWithTabletGCErrors) { TString value42(size_t(100 * 1024), 'a'); TString value43(size_t(100 * 1024), 'b'); @@ -679,7 +679,7 @@ Y_UNIT_TEST_SUITE(DataCleanup) { env.WaitFor<NFake::TEvCompacted>(); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(235); + executor->StartVacuum(235); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); @@ -700,13 +700,13 @@ Y_UNIT_TEST_SUITE(DataCleanup) { retriedGcResults.Stop(); auto ev2 = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->DataCleanupGeneration, 235); + UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->VacuumGeneration, 235); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value42), 0); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value43), 0); } - Y_UNIT_TEST(CleanupDataWithSysTabletGCErrors) { + Y_UNIT_TEST(StartVacuumWithSysTabletGCErrors) { TString value42 = "Some_value"; TMyEnvBase env; @@ -730,7 +730,7 @@ Y_UNIT_TEST_SUITE(DataCleanup) { env.SendSync(new NFake::TEvExecute{ new TTxDeleteRow(101, 42) }); env.SendSync(new NFake::TEvCall{ [](auto* executor, const auto& ctx) { - executor->CleanupData(235); + executor->StartVacuum(235); ctx.Send(ctx.SelfID, new NFake::TEvReturn); } }); @@ -741,7 +741,7 @@ Y_UNIT_TEST_SUITE(DataCleanup) { obs.Remove(); auto ev2 = env.GrabEdgeEvent<NFake::TEvDataCleaned>(); - UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->DataCleanupGeneration, 235); + UNIT_ASSERT_VALUES_EQUAL(ev2->Get()->VacuumGeneration, 235); UNIT_ASSERT_VALUES_EQUAL(BlobStorageValueCountInAllGroups(env, value42), 0); } diff --git a/ydb/core/tablet_flat/ut/ya.make b/ydb/core/tablet_flat/ut/ya.make index 9e942ae3efd..6bdc768edfc 100644 --- a/ydb/core/tablet_flat/ut/ya.make +++ b/ydb/core/tablet_flat/ut/ya.make @@ -38,7 +38,6 @@ SRCS( ut_comp_gen.cpp ut_compaction.cpp ut_compaction_multi.cpp - ut_data_cleanup.cpp ut_datetime.cpp ut_decimal.cpp ut_charge.cpp @@ -56,6 +55,7 @@ SRCS( ut_shared_sausagecache_actor.cpp ut_slice.cpp ut_slice_loader.cpp + ut_vacuum.cpp ut_versions.cpp ) diff --git a/ydb/core/tablet_flat/ya.make b/ydb/core/tablet_flat/ya.make index 0f8ece9144c..28b3734db0a 100644 --- a/ydb/core/tablet_flat/ya.make +++ b/ydb/core/tablet_flat/ya.make @@ -26,7 +26,6 @@ SRCS( flat_executor_compaction_logic.h flat_executor_counters.cpp flat_executor_counters.h - flat_executor_data_cleanup_logic.cpp flat_executor_db_mon.cpp flat_executor_gclogic.cpp flat_executor_gclogic.h @@ -36,6 +35,7 @@ SRCS( flat_executor_tx_env.h flat_executor_txloglogic.cpp flat_executor_txloglogic.h + flat_executor_vacuum_logic.cpp flat_fwd_misc.cpp flat_iterator.h flat_load_blob_queue.cpp diff --git a/ydb/core/tx/datashard/datashard__data_cleanup.cpp b/ydb/core/tx/datashard/datashard__data_cleanup.cpp index d6ed58aa07f..0283eef0f9c 100644 --- a/ydb/core/tx/datashard/datashard__data_cleanup.cpp +++ b/ydb/core/tx/datashard/datashard__data_cleanup.cpp @@ -69,7 +69,7 @@ public: } Self->OutReadSets.Cleanup(db, ctx); - Self->Executor()->CleanupData(Ev->Get()->Record.GetDataCleanupGeneration()); + Self->Executor()->StartVacuum(Ev->Get()->Record.GetDataCleanupGeneration()); Self->DataCleanupWaiters.insert({Ev->Get()->Record.GetDataCleanupGeneration(), Ev->Sender}); return true; } @@ -120,7 +120,7 @@ void TDataShard::Handle(TEvDataShard::TEvForceDataCleanup::TPtr& ev, const TActo Executor()->Execute(new TTxDataCleanup(this, ev), ctx); } -void TDataShard::DataCleanupComplete(ui64 dataCleanupGeneration, const TActorContext& ctx) { +void TDataShard::VacuumComplete(ui64 dataCleanupGeneration, const TActorContext& ctx) { Executor()->Execute(new TTxCompleteDataCleanup(this, dataCleanupGeneration), ctx); } diff --git a/ydb/core/tx/datashard/datashard_impl.h b/ydb/core/tx/datashard/datashard_impl.h index 98902b4d11b..e665c8b5381 100644 --- a/ydb/core/tx/datashard/datashard_impl.h +++ b/ydb/core/tx/datashard/datashard_impl.h @@ -1791,7 +1791,7 @@ public: void SnapshotComplete(TIntrusivePtr<NTabletFlatExecutor::TTableSnapshotContext> snapContext, const TActorContext &ctx) override; void CompactionComplete(ui32 tableId, const TActorContext &ctx) override; void CompletedLoansChanged(const TActorContext &ctx) override; - void DataCleanupComplete(ui64 dataCleanupGeneration, const TActorContext &ctx) override; + void VacuumComplete(ui64 dataCleanupGeneration, const TActorContext &ctx) override; void ReplyCompactionWaiters( ui32 tableId, |