diff options
author | Alberto Lerner <alerner@10gen.com> | 2010-10-26 09:52:50 -0400 |
---|---|---|
committer | Alberto Lerner <alerner@10gen.com> | 2010-10-26 09:52:50 -0400 |
commit | 5615486e98aad8859dfbe7b2bb4c8a71fa6cd419 (patch) | |
tree | d33d31a747a57cffbd63c5545e849749d5dfe184 | |
parent | 664cd5f069596f1aa40f666cbd1dc8a1c000f29b (diff) | |
download | mongo-5615486e98aad8859dfbe7b2bb4c8a71fa6cd419.tar.gz |
SERVER-1974 rollback version if migrate aborts on the TO side
-rw-r--r-- | s/d_migrate.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/s/d_migrate.cpp b/s/d_migrate.cpp index aaff993d291..6d2f32bab77 100644 --- a/s/d_migrate.cpp +++ b/s/d_migrate.cpp @@ -721,8 +721,10 @@ namespace mongo { // 5. { // 5.a + // we're under the collection lock here, so no other migrate can change maxVersion migrateFromStatus.setInCriticalSection( true ); - ShardChunkVersion myVersion = maxVersion; + ShardChunkVersion currVersion = maxVersion; + ShardChunkVersion myVersion = currVersion; myVersion.incMajor(); { @@ -730,9 +732,9 @@ namespace mongo { assert( myVersion > shardingState.getVersion( ns ) ); shardingState.setVersion( ns , myVersion ); assert( myVersion == shardingState.getVersion( ns ) ); - log() << "moveChunk locking myself to: " << myVersion << endl; } - + log() << "moveChunk locking myself to: " << myVersion << endl; + // 5.b { @@ -744,7 +746,13 @@ namespace mongo { connTo.done(); log() << "moveChunk commit result: " << res << endl; if ( ! ok ){ - log() << "_recvChunkCommit failed: " << res << endl; + { + dblock lk; + shardingState.setVersion( ns , currVersion ); + assert( currVersion == shardingState.getVersion( ns ) ); + } + log() << "_recvChunkCommit failed: " << res << " resetting shard version to: " << currVersion << endl; + errmsg = "_recvChunkCommit failed!"; result.append( "cause" , res ); return false; |