summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2013-07-20 13:59:57 -0400
committerGreg Studer <greg@10gen.com>2013-07-22 17:39:15 -0400
commitb51ad40a7b582baea1ba25b46020f6b4275878e9 (patch)
tree59a20ab285c86f85cfc7e4257730fea2d1eaa505 /src
parent3cf081b971bc0bc8efccf1b9591e95ec71a42d7c (diff)
downloadmongo-b51ad40a7b582baea1ba25b46020f6b4275878e9.tar.gz
SERVER-9365 make forced halfway split work with chunks with many docs
Additional test fixes.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/s/d_split.cpp17
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;