diff options
author | Eliot Horowitz <eliot@10gen.com> | 2010-05-24 17:24:41 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2010-05-24 17:24:41 -0400 |
commit | 4bdbf1fc6752891d9a37c3ff0381a3eda1634c88 (patch) | |
tree | 5b4bffb8f0cb9c21e210be05dfcae30b120f3056 /s/balance.cpp | |
parent | 375d5f729327b7177510f4f021b3e953d1d0efea (diff) | |
download | mongo-4bdbf1fc6752891d9a37c3ff0381a3eda1634c88.tar.gz |
use shared_ptr for Chunk references
handle splits on another server during splits SERVER-1109
Diffstat (limited to 's/balance.cpp')
-rw-r--r-- | s/balance.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/s/balance.cpp b/s/balance.cpp index 8c4485b87d2..79c234dbaff 100644 --- a/s/balance.cpp +++ b/s/balance.cpp @@ -163,14 +163,20 @@ namespace mongo { ChunkManager * cm = cfg->getChunkManager( ns ); assert( cm ); - Chunk& c = cm->findChunk( chunkToMove["min"].Obj() ); - if ( c.getMin().woCompare( chunkToMove["min"].Obj() ) ){ - log() << "balancer: weird chunk issue c: " << c << " min: " << chunkToMove["min"].Obj() << endl; - assert( c.getMin().woCompare( chunkToMove["min"].Obj() ) == 0 ); + ChunkPtr c = cm->findChunk( chunkToMove["min"].Obj() ); + if ( c->getMin().woCompare( chunkToMove["min"].Obj() ) ){ + // likely a split happened somewhere + cm = cfg->getChunkManager( ns , true ); + assert( cm ); + c = cm->findChunk( chunkToMove["min"].Obj() ); + if ( c->getMin().woCompare( chunkToMove["min"].Obj() ) ){ + log() << "balancer: chunk mismatch after reload, ignoring will retry issue cm: " << c->getMin() << " min: " << chunkToMove["min"].Obj() << endl; + return false; + } } string errmsg; - if ( c.moveAndCommit( Shard::make( to ) , errmsg ) ){ + if ( c->moveAndCommit( Shard::make( to ) , errmsg ) ){ return true; } |