Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

SERVER-6757 Map reduce collection drop test.

  • Loading branch information...
commit 1bac89b6f3b79507cac2e3272f03789467286e29 1 parent b1b0a1a
astaple authored August 21, 2012

Showing 1 changed file with 38 additions and 0 deletions. Show diff stats Hide diff stats

  1. 38  jstests/mr_drop.js
38  jstests/mr_drop.js
... ...
@@ -0,0 +1,38 @@
  1
+// Drop a collection while a map/reduce job is running against it.  SERVER-6757
  2
+
  3
+t = db.jstests_mr_drop;
  4
+t.drop();
  5
+
  6
+Random.setRandomSeed();
  7
+
  8
+// Set sleep times for different stages of the map/reduce job.  The collection drop will occur
  9
+// during different stages of map/reduce depending on these sleep values.
  10
+mapSleep = Random.randInt( 4 );
  11
+reduceSleep = Random.randInt( 4 );
  12
+finalizeSleep = Random.randInt( 4 );
  13
+
  14
+// Insert some documents.
  15
+for( i = 0; i < 1000; ++i ) {
  16
+    t.save( { key:parseInt( i / 2 ),
  17
+              mapSleep:mapSleep,
  18
+              reduceSleep:reduceSleep,
  19
+              finalizeSleep:finalizeSleep } );
  20
+}
  21
+db.getLastError();
  22
+
  23
+// Schedule a collection drop one second in the future.
  24
+s = startParallelShell( "sleep( 1000 ); db.jstests_mr_drop.drop();" );
  25
+
  26
+// Run the map/reduce job.  Check for command failure internally.  The job succeeds even if the
  27
+// source collection is dropped in progress.
  28
+t.mapReduce( function() { sleep( this.mapSleep ); emit( this.key, this ); },
  29
+             function( key, vals ) { sleep( vals[ 0 ].reduceSleep ); return vals[ 0 ]; },
  30
+             { finalize:function( key, value ) { sleep( value.finalizeSleep ); return value; },
  31
+               out:'jstests_mr_drop_out' }
  32
+           );
  33
+
  34
+// Wait for the parallel shell to finish.
  35
+s();
  36
+
  37
+// Ensure the server is still alive.  Under SERVER-6757 the server can crash.
  38
+assert( !db.getLastError() );

0 notes on commit 1bac89b

Please sign in to comment.
Something went wrong with that request. Please try again.