Permalink
Browse files

SERVER-1974 rollback version if migrate aborts on the TO side

  • Loading branch information...
1 parent 664cd5f commit 5615486e98aad8859dfbe7b2bb4c8a71fa6cd419 Alberto Lerner committed Oct 26, 2010
Showing with 12 additions and 4 deletions.
  1. +12 −4 s/d_migrate.cpp
View
@@ -721,18 +721,20 @@ 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();
{
dblock lk;
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;

0 comments on commit 5615486

Please sign in to comment.