summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/sharding/jumbo1.js4
-rw-r--r--src/mongo/db/s/balancer/balancer.cpp18
2 files changed, 19 insertions, 3 deletions
diff --git a/jstests/sharding/jumbo1.js b/jstests/sharding/jumbo1.js
index ee5516b0bd7..f3f0e8d2a9d 100644
--- a/jstests/sharding/jumbo1.js
+++ b/jstests/sharding/jumbo1.js
@@ -14,12 +14,15 @@
big += ".";
}
+ // Create sufficient documents to create a jumbo chunk, and use the same shard key in all of
+ // them so that the chunk cannot be split.
var x = 0;
var bulk = db.foo.initializeUnorderedBulkOp();
for (var i = 0; i < 500; i++) {
bulk.insert({x: x, big: big});
}
+ // Create documents with different shard keys that can be split and moved without issue.
for (; x < 1500; x++) {
bulk.insert({x: x, big: big});
}
@@ -43,6 +46,7 @@
return d < 5;
}, "balance didn't happen", 1000 * 60 * 5, 5000);
+ // Check that the jumbo chunk did not move, which shouldn't be possible.
var jumboChunk =
s.getDB('config').chunks.findOne({ns: 'test.foo', min: {$lte: {x: 0}}, max: {$gt: {x: 0}}});
assert.eq('shard0001', jumboChunk.shard, 'jumbo chunk ' + tojson(jumboChunk) + ' was moved');
diff --git a/src/mongo/db/s/balancer/balancer.cpp b/src/mongo/db/s/balancer/balancer.cpp
index 27b099935c7..4fddac5707f 100644
--- a/src/mongo/db/s/balancer/balancer.cpp
+++ b/src/mongo/db/s/balancer/balancer.cpp
@@ -327,9 +327,23 @@ void Balancer::_mainThread() {
break;
}
+ auto balancerConfig = shardingContext->getBalancerConfiguration();
+ while (!_stopRequested()) {
+ Status refreshStatus = balancerConfig->refreshAndCheck(txn.get());
+ if (!refreshStatus.isOK()) {
+ warning() << "Balancer settings could not be loaded and will be retried in "
+ << durationCount<Seconds>(kInitBackoffInterval) << " seconds"
+ << causedBy(refreshStatus);
+
+ _sleepFor(txn.get(), kInitBackoffInterval);
+ continue;
+ }
+
+ break;
+ }
+
log() << "CSRS balancer thread is recovering";
- auto balancerConfig = Grid::get(txn.get())->getBalancerConfiguration();
_migrationManager.finishRecovery(txn.get(),
balancerConfig->getMaxChunkSizeBytes(),
balancerConfig->getSecondaryThrottle(),
@@ -339,8 +353,6 @@ void Balancer::_mainThread() {
// Main balancer loop
while (!_stopRequested()) {
- auto balancerConfig = shardingContext->getBalancerConfiguration();
-
BalanceRoundDetails roundDetails;
_beginRound(txn.get());