diff options
10 files changed, 28 insertions, 27 deletions
diff --git a/ydb/core/tx/columnshard/background_controller.cpp b/ydb/core/tx/columnshard/background_controller.cpp index 1a26f8ed32f..e1c149cee39 100644 --- a/ydb/core/tx/columnshard/background_controller.cpp +++ b/ydb/core/tx/columnshard/background_controller.cpp @@ -3,15 +3,21 @@ namespace NKikimr::NColumnShard { -bool TBackgroundController::StartCompaction(const NOlap::TPlanCompactionInfo& info) { - auto it = ActiveCompactionInfo.find(info.GetPathId()); - if (it == ActiveCompactionInfo.end()) { - it = ActiveCompactionInfo.emplace(info.GetPathId(), info.GetPathId()).first; - } +bool TBackgroundController::StartCompaction(const TInternalPathId pathId) { + auto [it, _] = ActiveCompactionInfo.emplace(pathId, NOlap::TPlanCompactionInfo{pathId}); it->second.Start(); return true; } +void TBackgroundController::FinishCompaction(const TInternalPathId pathId) { + auto it = ActiveCompactionInfo.find(pathId); + AFL_VERIFY(it != ActiveCompactionInfo.end()); + if (it->second.Finish()) { + ActiveCompactionInfo.erase(it); + } + Counters->OnCompactionFinish(pathId); +} + void TBackgroundController::CheckDeadlines() { for (auto&& i : ActiveCompactionInfo) { if (TMonotonic::Now() - i.second.GetStartTime() > NOlap::TCompactionLimits::CompactionTimeout) { diff --git a/ydb/core/tx/columnshard/background_controller.h b/ydb/core/tx/columnshard/background_controller.h index fad6527fb56..bb5e0eb3ad8 100644 --- a/ydb/core/tx/columnshard/background_controller.h +++ b/ydb/core/tx/columnshard/background_controller.h @@ -47,15 +47,9 @@ public: void CheckDeadlines(); void CheckDeadlinesIndexation(); - bool StartCompaction(const NOlap::TPlanCompactionInfo& info); - void FinishCompaction(const NOlap::TPlanCompactionInfo& info) { - auto it = ActiveCompactionInfo.find(info.GetPathId()); - AFL_VERIFY(it != ActiveCompactionInfo.end()); - if (it->second.Finish()) { - ActiveCompactionInfo.erase(it); - } - Counters->OnCompactionFinish(info.GetPathId()); - } + bool StartCompaction(const TInternalPathId pathId); + void FinishCompaction(const TInternalPathId pathId); + ui32 GetCompactionsCount() const { return ActiveCompactionInfo.size(); } diff --git a/ydb/core/tx/columnshard/columnshard_impl.cpp b/ydb/core/tx/columnshard/columnshard_impl.cpp index 3f089c2b4d0..c53c4eb3085 100644 --- a/ydb/core/tx/columnshard/columnshard_impl.cpp +++ b/ydb/core/tx/columnshard/columnshard_impl.cpp @@ -835,7 +835,7 @@ void TColumnShard::SetupCompaction(const std::set<TInternalPathId>& pathIds) { if (BackgroundController.GetCompactionsCount()) { return; } - const ui64 priority = TablesManager.MutablePrimaryIndex().GetCompactionPriority(DataLocksManager, pathIds, BackgroundController.GetWaitingPriorityOptional()); + const ui64 priority = TablesManager.GetPrimaryIndexSafe().GetCompactionPriority(DataLocksManager, pathIds, BackgroundController.GetWaitingPriorityOptional()); if (priority) { BackgroundController.UpdateWaitingPriority(priority); if (pathIds.size()) { diff --git a/ydb/core/tx/columnshard/data_accessor/request.h b/ydb/core/tx/columnshard/data_accessor/request.h index 34876fd9cc3..d0eaf8051c7 100644 --- a/ydb/core/tx/columnshard/data_accessor/request.h +++ b/ydb/core/tx/columnshard/data_accessor/request.h @@ -127,7 +127,7 @@ public: return sb; } - TPathFetchingState(const TInternalPathId pathId) + explicit TPathFetchingState(const TInternalPathId pathId) : PathId(pathId) { } @@ -286,11 +286,12 @@ public: AFL_VERIFY(portion); AFL_VERIFY(FetchStage <= 1); AFL_VERIFY(PortionIds.emplace(portion->GetPortionId()).second); - PathIds.emplace(portion->GetPathId()); - auto it = PathIdStatus.find(portion->GetPathId()); + const auto& pathId = portion->GetPathId(); + PathIds.emplace(pathId); + auto it = PathIdStatus.find(pathId); if (it == PathIdStatus.end()) { PreparingCount.Inc(); - it = PathIdStatus.emplace(portion->GetPathId(), portion->GetPathId()).first; + it = PathIdStatus.emplace(pathId, TPathFetchingState{pathId}).first; } it->second.AddPortion(portion); } diff --git a/ydb/core/tx/columnshard/engines/changes/abstract/compaction_info.h b/ydb/core/tx/columnshard/engines/changes/abstract/compaction_info.h index b1f51d9d74a..fe99d6e8eb7 100644 --- a/ydb/core/tx/columnshard/engines/changes/abstract/compaction_info.h +++ b/ydb/core/tx/columnshard/engines/changes/abstract/compaction_info.h @@ -30,7 +30,7 @@ public: return StartTime; } - TPlanCompactionInfo(const TInternalPathId pathId) + explicit TPlanCompactionInfo(const TInternalPathId pathId) : PathId(pathId) { } diff --git a/ydb/core/tx/columnshard/engines/changes/compaction.cpp b/ydb/core/tx/columnshard/engines/changes/compaction.cpp index 40f08e502b8..61b9e021dba 100644 --- a/ydb/core/tx/columnshard/engines/changes/compaction.cpp +++ b/ydb/core/tx/columnshard/engines/changes/compaction.cpp @@ -32,7 +32,7 @@ void TCompactColumnEngineChanges::DoCompile(TFinalizationContext& context) { void TCompactColumnEngineChanges::DoStart(NColumnShard::TColumnShard& self) { TBase::DoStart(self); - self.BackgroundController.StartCompaction(NKikimr::NOlap::TPlanCompactionInfo(GranuleMeta->GetPathId())); + self.BackgroundController.StartCompaction(GranuleMeta->GetPathId()); NeedGranuleStatusProvide = true; GranuleMeta->OnCompactionStarted(); } @@ -45,7 +45,7 @@ void TCompactColumnEngineChanges::DoWriteIndexOnComplete(NColumnShard::TColumnSh } void TCompactColumnEngineChanges::DoOnFinish(NColumnShard::TColumnShard& self, TChangesFinishContext& context) { - self.BackgroundController.FinishCompaction(TPlanCompactionInfo(GranuleMeta->GetPathId())); + self.BackgroundController.FinishCompaction(GranuleMeta->GetPathId()); Y_ABORT_UNLESS(NeedGranuleStatusProvide); if (context.FinishedSuccessfully) { GranuleMeta->OnCompactionFinished(); diff --git a/ydb/core/tx/columnshard/engines/column_engine.h b/ydb/core/tx/columnshard/engines/column_engine.h index b7ef4f5f4ed..e6a268f4919 100644 --- a/ydb/core/tx/columnshard/engines/column_engine.h +++ b/ydb/core/tx/columnshard/engines/column_engine.h @@ -150,7 +150,7 @@ public: virtual std::shared_ptr<TInsertColumnEngineChanges> StartInsert(std::vector<TCommittedData>&& dataToIndex) noexcept = 0; virtual std::shared_ptr<TColumnEngineChanges> StartCompaction(const std::shared_ptr<NDataLocks::TManager>& dataLocksManager) noexcept = 0; virtual ui64 GetCompactionPriority(const std::shared_ptr<NDataLocks::TManager>& dataLocksManager, const std::set<TInternalPathId>& pathIds, - const std::optional<ui64> waitingPriority) noexcept = 0; + const std::optional<ui64> waitingPriority) const noexcept = 0; virtual std::shared_ptr<TCleanupPortionsColumnEngineChanges> StartCleanupPortions(const TSnapshot& snapshot, const THashSet<TInternalPathId>& pathsToDrop, const std::shared_ptr<NDataLocks::TManager>& dataLocksManager) noexcept = 0; virtual std::shared_ptr<TCleanupTablesColumnEngineChanges> StartCleanupTables(const THashSet<TInternalPathId>& pathsToDrop) noexcept = 0; diff --git a/ydb/core/tx/columnshard/engines/column_engine_logs.cpp b/ydb/core/tx/columnshard/engines/column_engine_logs.cpp index 2a9dd4be667..83520f7cc4e 100644 --- a/ydb/core/tx/columnshard/engines/column_engine_logs.cpp +++ b/ydb/core/tx/columnshard/engines/column_engine_logs.cpp @@ -189,7 +189,7 @@ std::shared_ptr<TInsertColumnEngineChanges> TColumnEngineForLogs::StartInsert(st } ui64 TColumnEngineForLogs::GetCompactionPriority(const std::shared_ptr<NDataLocks::TManager>& dataLocksManager, const std::set<TInternalPathId>& pathIds, - const std::optional<ui64> waitingPriority) noexcept { + const std::optional<ui64> waitingPriority) const noexcept { auto priority = GranulesStorage->GetCompactionPriority(dataLocksManager, pathIds, waitingPriority); if (!priority) { return 0; diff --git a/ydb/core/tx/columnshard/engines/column_engine_logs.h b/ydb/core/tx/columnshard/engines/column_engine_logs.h index 89a1838a301..63d2ec5d83e 100644 --- a/ydb/core/tx/columnshard/engines/column_engine_logs.h +++ b/ydb/core/tx/columnshard/engines/column_engine_logs.h @@ -147,7 +147,7 @@ public: } std::shared_ptr<TInsertColumnEngineChanges> StartInsert(std::vector<TCommittedData>&& dataToIndex) noexcept override; ui64 GetCompactionPriority(const std::shared_ptr<NDataLocks::TManager>& dataLocksManager, const std::set<TInternalPathId>& pathIds, - const std::optional<ui64> waitingPriority) noexcept override; + const std::optional<ui64> waitingPriority) const noexcept override; std::shared_ptr<TColumnEngineChanges> StartCompaction(const std::shared_ptr<NDataLocks::TManager>& dataLocksManager) noexcept override; std::shared_ptr<TCleanupPortionsColumnEngineChanges> StartCleanupPortions(const TSnapshot& snapshot, const THashSet<TInternalPathId>& pathsToDrop, const std::shared_ptr<NDataLocks::TManager>& dataLocksManager) noexcept override; diff --git a/ydb/core/tx/columnshard/engines/storage/optimizer/lbuckets/planner/optimizer.h b/ydb/core/tx/columnshard/engines/storage/optimizer/lbuckets/planner/optimizer.h index a5972524b30..0bb9984e8cf 100644 --- a/ydb/core/tx/columnshard/engines/storage/optimizer/lbuckets/planner/optimizer.h +++ b/ydb/core/tx/columnshard/engines/storage/optimizer/lbuckets/planner/optimizer.h @@ -1246,8 +1246,8 @@ protected: } virtual TOptimizationPriority DoGetUsefulMetric() const override { - if (Buckets.GetWeight()) { - return TOptimizationPriority::Critical(Buckets.GetWeight()); + if (const auto weight = Buckets.GetWeight()) { + return TOptimizationPriority::Critical(weight); } else { return TOptimizationPriority::Zero(); } |
