[SERVER-50757] Assess the usefulness of kAutoSplitOnly as a balancer mode Created: 03/Sep/20  Updated: 27/Oct/23  Resolved: 18/Sep/20

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Blake Oler Assignee: Randolph Tan
Resolution: Works as Designed Votes: 0
Labels: sharding-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Sprint: Sharding 2020-09-21
Participants:

 Description   

We have autoSplitOnly as an available mode for the balancer, but we don't use this mode anywhere in current server code. It may simplify the balancer to remove it completely.



 Comments   
Comment by Randolph Tan [ 17/Sep/20 ]

Note that these two settings are knobs for different things. The balancer mode is for enabling top-chunk moveChunk during autoSplit even when balancer will not be moving any chunks and the autoSplit setting is for completely turning autoSplit on/off. kAutoSplitOnly is not directly used, but it's existence has an effect on the behavior of current code. The auto split code uses shouldBalanceForAutoSplit to determine whether it is allowed to moveChunks. Note that the condition "(mode == off) return false;" is logically equivalent to "(mode == autoSplitOnly || mode == full) return true;".

Comment by Blake Oler [ 09/Sep/20 ]

Talked about this offline with Max. We came to the conclusion that nowhere in server code is kAutoSplitOnly actually used. Thankfully though, it seems like kAutoSplitOnly works as it should if anyone ever uses it. Whoever picks up this ticket will be tasked with making sense of two parameters – the kAutoSplitOnly balancer mode and this separate autosplit setting. The end result should be a cohesive approach cleanly unifying these parameters.

Comment by Max Hirschhorn [ 09/Sep/20 ]

blake.oler, I'd expect the std::find() below to be setting BalancerConfiguration::_mode to BalancerSettingsType::kAutoSplitOnly. This would make BalancerConfiguration::shouldBalance() return false but not BalancerConfiguration::shouldBalanceForAutoSplit().

std::string modeStr;
status = bsonExtractStringFieldWithDefault(obj, kMode, kBalancerModes[kFull], &modeStr);
if (!status.isOK())
    return status;
auto it = std::find(std::begin(kBalancerModes), std::end(kBalancerModes), modeStr);
if (it == std::end(kBalancerModes)) {
    return Status(ErrorCodes::BadValue, "Invalid balancer mode");
}
 
settings._mode = static_cast<BalancerMode>(it - std::begin(kBalancerModes));

Generated at Thu Feb 08 05:23:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.