diff options
author | Alberto Lerner <alerner@10gen.com> | 2010-10-20 16:32:49 -0400 |
---|---|---|
committer | Alberto Lerner <alerner@10gen.com> | 2010-12-29 12:43:14 -0500 |
commit | ada376198a7d5a3004d95c76f8a4fe58e9058da3 (patch) | |
tree | 879a443155373fe0ca745125f3c36d650e01109c | |
parent | 2f0f69fb6568f0a923740bb469b2e158a3f6e8e6 (diff) | |
download | mongo-ada376198a7d5a3004d95c76f8a4fe58e9058da3.tar.gz |
SERVER-1979 check max key before accepting a move request
-rw-r--r-- | s/d_migrate.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/s/d_migrate.cpp b/s/d_migrate.cpp index 8e9584c7009..6ddd9667b46 100644 --- a/s/d_migrate.cpp +++ b/s/d_migrate.cpp @@ -475,10 +475,24 @@ namespace mongo { BSONObj x = conn->findOne( ShardNS::chunk , Query( BSON( "ns" << ns ) ).sort( BSON( "lastmod" << -1 ) ) ); maxVersion = x["lastmod"]; - x = conn->findOne( ShardNS::chunk , shardId.wrap( "_id" ) ); - assert( x["shard"].type() ); - myOldShard = x["shard"].String(); + BSONObj currChunk = conn->findOne( ShardNS::chunk , shardId.wrap( "_id" ) ); + assert( currChunk["shard"].type() ); + assert( currChunk["min"].type() ); + assert( currChunk["max"].type() ); + myOldShard = currChunk["shard"].String(); + conn.done(); + BSONObj currMin = currChunk["min"].Obj(); + BSONObj currMax = currChunk["max"].Obj(); + if ( currMin.woCompare( min ) || currMax.woCompare( max ) ) { + errmsg = "chunk boundaries are outdated (likely a split occurred)"; + result.append( "currMin" , currMin ); + result.append( "currMax" , currMax ); + result.append( "requestedMin" , min ); + result.append( "requestedMax" , max ); + return false; + } + if ( myOldShard != fromShard.getName() ){ errmsg = "i'm out of date"; result.append( "from" , fromShard.getName() ); @@ -493,7 +507,6 @@ namespace mongo { return false; } - conn.done(); } timing.done(2); |