diff options
Diffstat (limited to 'src/mongo/s/d_split.cpp')
-rw-r--r-- | src/mongo/s/d_split.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/mongo/s/d_split.cpp b/src/mongo/s/d_split.cpp index 332a6300014..d28f3f5d90b 100644 --- a/src/mongo/s/d_split.cpp +++ b/src/mongo/s/d_split.cpp @@ -290,13 +290,14 @@ namespace mongo { // 'force'-ing a split is equivalent to having maxChunkSize be the size of the current chunk, i.e., the // logic below will split that chunk in half long long maxChunkSize = 0; - bool force = false; + bool forceMedianSplit = false; { BSONElement maxSizeElem = jsobj[ "maxChunkSize" ]; BSONElement forceElem = jsobj[ "force" ]; if ( forceElem.trueValue() ) { - force = true; + forceMedianSplit = true; + // This chunk size is effectively ignored if force is true maxChunkSize = dataSize; } @@ -366,7 +367,8 @@ namespace mongo { while ( cc->ok() ) { currCount++; - if ( currCount > keyCount ) { + if ( currCount > keyCount && !forceMedianSplit ) { + BSONObj currKey = bc->prettyKey( c->currKey() ).extractFields(keyPattern); // Do not use this split key if it is the same used in the previous split point. if ( currKey.woCompare( splitKeys.back() ) == 0 ) { @@ -404,10 +406,15 @@ namespace mongo { } } - if ( splitKeys.size() > 1 || ! force ) + if ( ! forceMedianSplit ) break; - force = false; + // + // If we're forcing a split at the halfway point, then the first pass was just + // to count the keys, and we still need a second pass. + // + + forceMedianSplit = false; keyCount = currCount / 2; currCount = 0; log() << "splitVector doing another cycle because of force, keyCount now: " << keyCount << endl; |