diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-02-16 15:51:25 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-02-16 15:51:25 -0500 |
commit | a4153eb6edcf3975afed2f33f7595fee2dd6a71b (patch) | |
tree | 0703319bcd561bcb96112e9db9d1ce7a29e64903 /jstests/sharding/migrateBig.js | |
parent | e690bfef3ca96c156db17e9be6580daa8118e9a9 (diff) | |
download | mongo-a4153eb6edcf3975afed2f33f7595fee2dd6a71b.tar.gz |
If migrate fails due to oversized chunk, try to split that chunk SERVER-2519
Diffstat (limited to 'jstests/sharding/migrateBig.js')
-rw-r--r-- | jstests/sharding/migrateBig.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/jstests/sharding/migrateBig.js b/jstests/sharding/migrateBig.js new file mode 100644 index 00000000000..f6ba18a7c02 --- /dev/null +++ b/jstests/sharding/migrateBig.js @@ -0,0 +1,45 @@ + +s = new ShardingTest( "migrateBig" , 2 , 0 , 1 , { chunksize : 1 } ); + +s.adminCommand( { enablesharding : "test" } ); +s.adminCommand( { shardcollection : "test.foo" , key : { x : 1 } } ); + +db = s.getDB( "test" ) +coll = db.foo + +big = "" +while ( big.length < 10000 ) + big += "eliot" + +for ( x=0; x<100; x++ ) + coll.insert( { x : x , big : big } ) + +s.adminCommand( { split : "test.foo" , middle : { x : 33 } } ) +s.adminCommand( { split : "test.foo" , middle : { x : 66 } } ) +s.adminCommand( { movechunk : "test.foo" , find : { x : 90 } , to : s.getOther( s.getServer( "test" ) ).name } ) + +db.printShardingStatus() + +print( "YO : " + s.getServer( "test" ).host ) +direct = new Mongo( s.getServer( "test" ).host ) +print( "direct : " + direct ) + +directDB = direct.getDB( "test" ) + +for ( done=0; done<2*1024*1024; done+=big.length ){ + directDB.foo.insert( { x : 50 + Math.random() , big : big } ) + directDB.getLastError(); +} + +db.printShardingStatus() + +assert.throws( function(){ s.adminCommand( { movechunk : "test.foo" , find : { x : 50 } , to : s.getOther( s.getServer( "test" ) ).name } ); } , [] , "move should fail" ) + +for ( i=0; i<20; i+= 2 ) + s.adminCommand( { split : "test.foo" , middle : { x : i } } ) + +db.printShardingStatus() + +assert.soon( function(){ var x = s.chunkDiff( "foo" , "test" ); print( "chunk diff: " + x ); return x < 2; } , "no balance happened" , 120 * 1000 , 2000 ) + +s.stop() |