diff --git a/s/chunk.cpp b/s/chunk.cpp index e32c223349c..5b093d8159e 100644 --- a/s/chunk.cpp +++ b/s/chunk.cpp @@ -45,15 +45,18 @@ namespace mongo { int Chunk::MaxChunkSize = 1024 * 1024 * 64; - Chunk::Chunk( ChunkManager * manager ) - : _manager(manager), - _lastmod(0), _dataWritten(0) - {} + Chunk::Chunk( ChunkManager * manager ) : _manager(manager), _lastmod(0) { + _setDataWritten(); + } Chunk::Chunk(ChunkManager * info , const BSONObj& min, const BSONObj& max, const Shard& shard) - : _manager(info), _min(min), _max(max), _shard(shard), - _lastmod(0), _dataWritten(0) - {} + : _manager(info), _min(min), _max(max), _shard(shard), _lastmod(0) { + _setDataWritten(); + } + + void Chunk::_setDataWritten(){ + _dataWritten = rand() % ( MaxChunkSize / 5 ); + } string Chunk::getns() const { assert( _manager ); diff --git a/s/chunk.h b/s/chunk.h index d0d35f56215..92560aeb9d8 100644 --- a/s/chunk.h +++ b/s/chunk.h @@ -210,6 +210,9 @@ namespace mongo { */ BSONObj _getExtremeKey( int sort ) const; + /** initializes _dataWritten with a random value so that a mongos restart wouldn't cause delay in splitting */ + void _setDataWritten(); + ShardKeyPattern skey() const; };