diff options
-rw-r--r-- | src/mongo/s/d_migrate.cpp | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp index 139a640f5ce..69390e331b8 100644 --- a/src/mongo/s/d_migrate.cpp +++ b/src/mongo/s/d_migrate.cpp @@ -1252,49 +1252,48 @@ namespace mongo { // 5.b // we're under the collection lock here, too, so we can undo the chunk donation because no other state change // could be ongoing - { - BSONObj res; + + BSONObj res; + bool ok; + + try { scoped_ptr<ScopedDbConnection> connTo( ScopedDbConnection::getScopedDbConnection( toShard.getConnString(), 35.0 ) ); - - bool ok; - - try{ - ok = connTo->get()->runCommand( "admin" , - BSON( "_recvChunkCommit" << 1 ) , - res ); - } - catch( DBException& e ){ - errmsg = str::stream() << "moveChunk could not contact to: shard " << toShard.getConnString() << " to commit transfer" << causedBy( e ); - warning() << errmsg << endl; - ok = false; - } - + ok = connTo->get()->runCommand( "admin", BSON( "_recvChunkCommit" << 1 ), res ); connTo->done(); + } + catch ( DBException& e ) { + errmsg = str::stream() << "moveChunk could not contact to: shard " + << toShard.getConnString() << " to commit transfer" + << causedBy( e ); + warning() << errmsg << endl; + ok = false; + } - if ( ! ok ) { - log() << "moveChunk migrate commit not accepted by TO-shard: " << res - << " resetting shard version to: " << startingVersion << migrateLog; - { - Lock::GlobalWrite lk; - log() << "moveChunk global lock acquired to reset shard version from " - "failed migration" << endl; - - // revert the chunk manager back to the state before "forgetting" about the chunk - shardingState.undoDonateChunk( ns , min , max , startingVersion ); - } - log() << "Shard version successfully reset to clean up failed migration" - << endl; + if ( !ok ) { + log() << "moveChunk migrate commit not accepted by TO-shard: " << res + << " resetting shard version to: " << startingVersion << migrateLog; + { + Lock::GlobalWrite lk; + log() << "moveChunk global lock acquired to reset shard version from " + "failed migration" + << endl; - errmsg = "_recvChunkCommit failed!"; - result.append( "cause" , res ); - return false; + // revert the chunk manager back to the state before "forgetting" about the + // chunk + shardingState.undoDonateChunk( ns, min, max, startingVersion ); } + log() << "Shard version successfully reset to clean up failed migration" + << endl; - log() << "moveChunk migrate commit accepted by TO-shard: " << res << migrateLog; + errmsg = "_recvChunkCommit failed!"; + result.append( "cause", res ); + return false; } + log() << "moveChunk migrate commit accepted by TO-shard: " << res << migrateLog; + // 5.c // version at which the next highest lastmod will be set @@ -1404,7 +1403,7 @@ namespace mongo { LOG(7) << "moveChunk update: " << cmd << migrateLog; int exceptionCode = OkCode; - bool ok = false; + ok = false; BSONObj cmdResult; try { scoped_ptr<ScopedDbConnection> conn( |