Skip to content

Commit

Permalink
SERVER-5004 Do not start new chunk moves if balancer is disabled mid …
Browse files Browse the repository at this point in the history
…balancing round
  • Loading branch information
stbrody committed Feb 25, 2015
1 parent 2d6aefa commit bfe2e9e
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/mongo/s/balance.cpp
Expand Up @@ -85,11 +85,33 @@ namespace mongo {
int movedCount = 0;

for ( vector<CandidateChunkPtr>::const_iterator it = candidateChunks->begin(); it != candidateChunks->end(); ++it ) {
const CandidateChunk& chunkInfo = *it->get();

// Changes to metadata, borked metadata, and connectivity problems should cause us to
// abort this chunk move, but shouldn't cause us to abort the entire round of chunks.
// If the balancer was disabled since we started this round, don't start new
// chunks moves.
SettingsType balancerConfig;
std::string errMsg;

if (!grid.getBalancerSettings(&balancerConfig, &errMsg)) {
warning() << errMsg;
// No point in continuing the round if the config servers are unreachable.
return movedCount;
}

if ((balancerConfig.isKeySet() && // balancer config doc exists
!grid.shouldBalance(balancerConfig)) ||
MONGO_FAIL_POINT(skipBalanceRound)) {
LOG(1) << "Stopping balancing round early as balancing was disabled";
return movedCount;
}

// Changes to metadata, borked metadata, and connectivity problems between shards should
// cause us to abort this chunk move, but shouldn't cause us to abort the entire round
// of chunks.
// TODO(spencer): We probably *should* abort the whole round on issues communicating
// with the config servers, but its impossible to distinguish those types of failures
// at the moment.
// TODO: Handle all these things more cleanly, since they're expected problems
const CandidateChunk& chunkInfo = *it->get();
try {

DBConfigPtr cfg = grid.getDBConfig( chunkInfo.ns );
Expand Down

0 comments on commit bfe2e9e

Please sign in to comment.