diff options
author | Kevin Matulef <matulef@gmail.com> | 2012-09-11 23:53:13 -0400 |
---|---|---|
committer | Kevin Matulef <matulef@gmail.com> | 2012-09-11 23:57:37 -0400 |
commit | 64429ff8c5f485b138f01fb05f2b78cb144d90ff (patch) | |
tree | c1351aa1f4eba961556739fd25194977450bc55b /jstests/sharding/delete_during_migrate.js | |
parent | 5bd5648464b5582c3b3e109f63fc1bf63c1e6148 (diff) | |
download | mongo-64429ff8c5f485b138f01fb05f2b78cb144d90ff.tar.gz |
SERVER-7003 fix migrations in the presence of active deletions
Diffstat (limited to 'jstests/sharding/delete_during_migrate.js')
-rw-r--r-- | jstests/sharding/delete_during_migrate.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/jstests/sharding/delete_during_migrate.js b/jstests/sharding/delete_during_migrate.js new file mode 100644 index 00000000000..4b01d16734a --- /dev/null +++ b/jstests/sharding/delete_during_migrate.js @@ -0,0 +1,42 @@ +// Test migrating a big chunk while deletions are happening within that chunk. +// Test is slightly non-deterministic, since removes could happen before migrate +// starts. Protect against that by making chunk very large. + +// start up a new sharded cluster +var st = new ShardingTest({ shards : 2, mongos : 1 }); + +// stop balancer since we want manual control for this +st.stopBalancer(); + +var dbname = "testDB"; +var coll = "foo"; +var ns = dbname + "." + coll; +var s = st.s0; +var t = s.getDB( dbname ).getCollection( coll ); + +// Create fresh collection with lots of docs +t.drop(); +for ( i=0; i<200000; i++ ){ + t.insert( { a : i } ); +} + +// enable sharding of the collection. Only 1 chunk. +t.ensureIndex( { a : 1 } ); +s.adminCommand( { enablesharding : dbname } ); +s.adminCommand( { shardcollection : ns , key: { a : 1 } } ); + +// start a parallel shell that deletes things +startMongoProgramNoConnect( "mongo" , + "--host" , getHostName() , + "--port" , st.s0.port , + "--eval" , "db." + coll + ".remove({});" , + dbname ); + +// migrate while deletions are happening +var moveResult = s.adminCommand( { moveChunk : ns , + find : { a : 1 } , + to : st.getOther( st.getServer( dbname ) ).name } ); +// check if migration worked +assert( moveResult.ok , "migration didn't work while doing deletes" ); + +st.stop(); |