diff options
| author | Laszlo Boszormenyi (GCS) <gcs@debian.org> | 2013-10-18 10:31:13 +0200 |
|---|---|---|
| committer | Laszlo Boszormenyi (GCS) <gcs@debian.org> | 2013-10-18 10:31:13 +0200 |
| commit | 65585c90b12d6523bea75a2aebaae2a2fdf9e641 (patch) | |
| tree | ccb3081edfe67f988844af661a2bf93aa95ae09f /src/mongo/s/d_split.cpp | |
| parent | e3904bf97e74cbbe5dde6b3abc3e797ad7d26b5d (diff) | |
Imported Upstream version 2.4.6upstream/2.4.6
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 5231e9e571b..86f9d5ef728 100644 --- a/src/mongo/s/d_split.cpp +++ b/src/mongo/s/d_split.cpp @@ -289,13 +289,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; } @@ -365,7 +366,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 ) { @@ -403,10 +405,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; |
