diff options
author | zalyalov <[email protected]> | 2023-10-11 11:12:00 +0300 |
---|---|---|
committer | zalyalov <[email protected]> | 2023-10-11 11:49:23 +0300 |
commit | b95dc8e862f26368aa0275e2571eefe238c1951e (patch) | |
tree | 36abae02838a28dfd7b7b198f7288d941095bee7 | |
parent | 5358119d432f0b81ccf781e8c0f5bd2e5fc5bce9 (diff) |
add a way to turn off computation of object distribution
-rw-r--r-- | ydb/core/mind/hive/hive_impl.cpp | 11 | ||||
-rw-r--r-- | ydb/core/mind/hive/hive_impl.h | 2 | ||||
-rw-r--r-- | ydb/core/mind/hive/object_distribution.h | 22 |
3 files changed, 33 insertions, 2 deletions
diff --git a/ydb/core/mind/hive/hive_impl.cpp b/ydb/core/mind/hive/hive_impl.cpp index d994d8a88a6..b5497776c1e 100644 --- a/ydb/core/mind/hive/hive_impl.cpp +++ b/ydb/core/mind/hive/hive_impl.cpp @@ -593,6 +593,13 @@ void THive::BuildCurrentConfig() { } } MakeTabletTypeSet(BalancerIgnoreTabletTypes); + if (!CurrentConfig.GetSpreadNeighbours()) { + // SpreadNeighbours can be turned off anytime, but + // cannot be safely turned on without Hive restart + // as the in-memory data on neighbours would not be accurate + SpreadNeighbours = false; + ObjectDistributions.Disable(); + } } void THive::Cleanup() { @@ -915,6 +922,7 @@ void THive::OnActivateExecutor(const TActorContext&) { ResourceProfiles = AppData()->ResourceProfiles ? AppData()->ResourceProfiles : new TResourceProfiles; BuildLocalConfig(); ClusterConfig = AppData()->HiveConfig; + SpreadNeighbours = ClusterConfig.GetSpreadNeighbours(); Send(NConsole::MakeConfigsDispatcherID(SelfId().NodeId()), new NConsole::TEvConfigsDispatcher::TEvSetConfigSubscriptionRequest(NKikimrConsole::TConfigItem::HiveConfigItem)); Execute(CreateInitScheme()); @@ -2577,6 +2585,9 @@ TDuration THive::GetBalancerCooldown() const { } void THive::UpdateObjectCount(TObjectId object, TNodeId node, i64 diff) { + if (!GetSpreadNeighbours()) { + return; + } ObjectDistributions.UpdateCount(object, node, diff); TabletCounters->Simple()[NHive::COUNTER_IMBALANCED_OBJECTS].Set(ObjectDistributions.GetImbalancedObjectsCount()); TabletCounters->Simple()[NHive::COUNTER_WORST_OBJECT_VARIANCE].Set(ObjectDistributions.GetWorstObjectVariance()); diff --git a/ydb/core/mind/hive/hive_impl.h b/ydb/core/mind/hive/hive_impl.h index 1b5edbe8647..6fd8aab2146 100644 --- a/ydb/core/mind/hive/hive_impl.h +++ b/ydb/core/mind/hive/hive_impl.h @@ -771,7 +771,7 @@ public: } bool GetSpreadNeighbours() const { - return CurrentConfig.GetSpreadNeighbours(); + return SpreadNeighbours; } ui64 GetDefaultUnitIOPS() const { diff --git a/ydb/core/mind/hive/object_distribution.h b/ydb/core/mind/hive/object_distribution.h index 06396044b05..e441741bc10 100644 --- a/ydb/core/mind/hive/object_distribution.h +++ b/ydb/core/mind/hive/object_distribution.h @@ -87,6 +87,7 @@ struct TObjectDistributions { std::unordered_map<TObjectId, std::multiset<TObjectDistribution>::iterator> Distributions; ui64 ImbalancedObjects = 0; std::unordered_set<TNodeId> Nodes; + bool Enabled = true; double GetMaxImbalance() { if (SortedDistributions.empty()) { @@ -103,7 +104,10 @@ struct TObjectDistributions { }; TObjectToBalance GetObjectToBalance() { - Y_ABORT_UNLESS(!SortedDistributions.empty()); + Y_DEBUG_ABORT_UNLESS(!SortedDistributions.empty()); + if (SortedDistributions.empty()) { + return TObjectToBalance(0); + } const auto& dist = *SortedDistributions.rbegin(); i64 maxCnt = *dist.SortedDistribution.rbegin(); TObjectToBalance result(dist.Id); @@ -159,6 +163,9 @@ struct TObjectDistributions { void UpdateCount(TObjectId object, TNodeId node, i64 diff) { + if (!Enabled) { + return; + } auto updateFunc = [=](TObjectDistribution& dist) { dist.UpdateCount(node, diff); }; @@ -176,6 +183,9 @@ struct TObjectDistributions { } void AddNode(TNodeId node) { + if (!Enabled) { + return; + } Nodes.insert(node); for (const auto& [obj, it] : Distributions) { UpdateCount(obj, node, 0); @@ -183,6 +193,9 @@ struct TObjectDistributions { } void RemoveNode(TNodeId node) { + if (!Enabled) { + return; + } Nodes.erase(node); auto updateFunc = [=](TObjectDistribution& dist) { dist.RemoveNode(node); @@ -191,6 +204,13 @@ struct TObjectDistributions { UpdateDistribution((it++)->first, updateFunc); } } + + void Disable() { + Enabled = false; + Nodes.clear(); + SortedDistributions.clear(); + Distributions.clear(); + } }; } // NHive |