summaryrefslogtreecommitdiff
path: root/jstests/sharding/sharding_migrate_cursor1.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/sharding/sharding_migrate_cursor1.js')
-rw-r--r--jstests/sharding/sharding_migrate_cursor1.js40
1 files changed, 20 insertions, 20 deletions
diff --git a/jstests/sharding/sharding_migrate_cursor1.js b/jstests/sharding/sharding_migrate_cursor1.js
index 81b91eb420a..86814ed17a8 100644
--- a/jstests/sharding/sharding_migrate_cursor1.js
+++ b/jstests/sharding/sharding_migrate_cursor1.js
@@ -1,7 +1,7 @@
// SERVER-2068
(function() {
-var chunkSize = 25
+var chunkSize = 25;
var s = new ShardingTest({ name: "migrate_cursor1",
shards: 2,
@@ -9,22 +9,22 @@ var s = new ShardingTest({ name: "migrate_cursor1",
other: { chunkSize : chunkSize } });
s.adminCommand( { enablesharding : "test" } );
-db = s.getDB( "test" )
+db = s.getDB( "test" );
s.ensurePrimaryShard('test', 'shard0001');
-t = db.foo
+t = db.foo;
-bigString = ""
+bigString = "";
stringSize = 1024;
while ( bigString.length < stringSize )
bigString += "asdasdas";
-stringSize = bigString.length
-docsPerChunk = Math.ceil( ( chunkSize * 1024 * 1024 ) / ( stringSize - 12 ) )
-numChunks = 5
-numDocs = 20 * docsPerChunk
+stringSize = bigString.length;
+docsPerChunk = Math.ceil( ( chunkSize * 1024 * 1024 ) / ( stringSize - 12 ) );
+numChunks = 5;
+numDocs = 20 * docsPerChunk;
-print( "stringSize: " + stringSize + " docsPerChunk: " + docsPerChunk + " numDocs: " + numDocs )
+print( "stringSize: " + stringSize + " docsPerChunk: " + docsPerChunk + " numDocs: " + numDocs );
var bulk = t.initializeUnorderedBulkOp();
for (var i = 0; i < numDocs; i++){
@@ -37,35 +37,35 @@ s.adminCommand( { shardcollection : "test.foo" , key : { _id : 1 } } );
assert.lt( numChunks , s.config.chunks.find().count() , "initial 1" );
primary = s.getServer( "test" ).getDB( "test" ).foo;
-secondaryName = s.getOther( primary.name )
+secondaryName = s.getOther( primary.name );
secondary = secondaryName.getDB( "test" ).foo;
assert.eq( numDocs , primary.count() , "initial 2" );
assert.eq( 0 , secondary.count() , "initial 3" );
-assert.eq( numDocs , t.count() , "initial 4" )
+assert.eq( numDocs , t.count() , "initial 4" );
-x = primary.find( { _id : { $lt : 500 } } ).batchSize(2)
+x = primary.find( { _id : { $lt : 500 } } ).batchSize(2);
x.next(); // 1. Create an open cursor
-print("start moving chunks...")
+print("start moving chunks...");
// 2. Move chunk from s0 to s1 without waiting for deletion.
// Command returns, but the deletion on s0 will block due to the open cursor.
-s.adminCommand( { moveChunk : "test.foo" , find : { _id : 0 } , to : secondaryName.name } )
+s.adminCommand( { moveChunk : "test.foo" , find : { _id : 0 } , to : secondaryName.name } );
// 3. Start second moveChunk command from s0 to s1.
// This moveChunk should not observe the above deletion as a 'mod', transfer it to s1 and cause deletion on s1.
// This moveChunk will wait for deletion.
-join = startParallelShell( "db.x.insert( {x:1} ); db.adminCommand( { moveChunk : 'test.foo' , find : { _id : " + docsPerChunk * 3 + " } , to : '" + secondaryName.name + "', _waitForDelete: true } )" )
-assert.soon( function(){ return db.x.count() > 0; } , "XXX" , 30000 , 1 )
+join = startParallelShell( "db.x.insert( {x:1} ); db.adminCommand( { moveChunk : 'test.foo' , find : { _id : " + docsPerChunk * 3 + " } , to : '" + secondaryName.name + "', _waitForDelete: true } )" );
+assert.soon( function(){ return db.x.count() > 0; } , "XXX" , 30000 , 1 );
// 4. Close the cursor to enable chunk deletion.
-print( "itcount: " + x.itcount() )
+print( "itcount: " + x.itcount() );
x = null;
-for ( i=0; i<5; i++ ) gc()
+for ( i=0; i<5; i++ ) gc();
-print( "cursor should be gone" )
+print( "cursor should be gone" );
// 5. Waiting for the second moveChunk to finish its deletion.
// Note the deletion for the first moveChunk may not be finished.
@@ -74,7 +74,7 @@ join();
//assert.soon( function(){ return numDocs == t.count(); } , "at end 1" )
// 6. Check the total number of docs on both shards to make sure no doc is lost.
// Use itcount() to ignore orphan docments.
-assert.eq( numDocs , t.find().itcount() , "at end 2" )
+assert.eq( numDocs , t.find().itcount() , "at end 2" );
s.stop();