diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-11-01 00:56:17 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-11-01 00:56:47 -0400 |
commit | 975be960bb8617723b93c971d2f2afdc74550146 (patch) | |
tree | 52bffb3a513f42d7f8321c9c4201257b3805964c | |
parent | ebdb2b61f308b4bee2252b2a7effa047b2c71205 (diff) | |
download | mongo-975be960bb8617723b93c971d2f2afdc74550146.tar.gz |
when splitting chunk thas has a max inf edge, don't leave a chunk bigger than max chunk size
-rw-r--r-- | s/chunk.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/s/chunk.cpp b/s/chunk.cpp index 3d20c9fa5b2..8587d97ad65 100644 --- a/s/chunk.cpp +++ b/s/chunk.cpp @@ -196,12 +196,12 @@ namespace mongo { BSONObj Chunk::singleSplit( bool force , BSONObj& res ) const { vector<BSONObj> splitPoint; - + vector<BSONObj> candidates; + // if splitting is not obligatory we may return early if there are not enough data // we cap the number of objects that would fall in the first half (before the split point) // the rationale is we'll find a split point without traversing all the data if ( ! force ) { - vector<BSONObj> candidates; const int maxPoints = 2; pickSplitVector( candidates , getManager()->getCurrentDesiredChunkSize() , maxPoints , MaxObjectPerChunk ); if ( candidates.size() <= 1 ) { @@ -211,7 +211,7 @@ namespace mongo { LOG(1) << "chunk not full enough to trigger auto-split" << endl; return BSONObj(); } - + splitPoint.push_back( candidates.front() ); } @@ -235,10 +235,19 @@ namespace mongo { } else if ( maxIsInf() ) { - splitPoint.clear(); - BSONObj key = _getExtremeKey( -1 ); - if ( ! key.isEmpty() ) { - splitPoint.push_back( key ); + + if ( candidates.size() > 1 ) { + // this is so that we don't end up with a chunnk + // that is larger than the max chunk size + splitPoint.clear(); + splitPoint.push_back( candidates[1] ); + } + else { + BSONObj key = _getExtremeKey( -1 ); + if ( ! key.isEmpty() ) { + splitPoint.clear(); + splitPoint.push_back( key ); + } } } |