summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Stearn <redbeard0531@gmail.com>2017-01-18 14:24:26 -0500
committerMathias Stearn <redbeard0531@gmail.com>2017-01-18 14:24:26 -0500
commit1b45a872f86bcb230c3e70e00bb05622d538a793 (patch)
tree02a3ddd93abe8506e9293e1e45bbcc73b8085ad7
parent3c2c8f709d7043d22d1161fce807c40e4d624742 (diff)
downloadmongo-1b45a872f86bcb230c3e70e00bb05622d538a793.tar.gz
Revert "SERVER-25286 rewrite drop2.js to not depend on count scan yield behavior"
This reverts commit 3c2c8f709d7043d22d1161fce807c40e4d624742.
-rw-r--r--buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml1
-rw-r--r--buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml1
-rw-r--r--jstests/core/drop2.js57
-rw-r--r--jstests/core/killop_drop_collection.js55
-rw-r--r--jstests/libs/parallelTester.js2
5 files changed, 58 insertions, 58 deletions
diff --git a/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml
index e88028fcb41..32ad9399d63 100644
--- a/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml
@@ -68,7 +68,6 @@ selector:
- jstests/core/eval0.js
- jstests/core/eval7.js
- jstests/core/eval9.js
- - jstests/core/killop_drop_collection.js # Uses fsyncLock.
executor:
js_test:
diff --git a/buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml
index db5e043b209..a1758adb65c 100644
--- a/buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml
@@ -42,7 +42,6 @@ selector:
# TODO: SERVER-18292 remove once OP_COMMAND is implemented in mongos.
- jstests/core/invalid_db_name.js
- jstests/core/validate_cmd_ns.js
- - jstests/core/killop_drop_collection.js # Uses fsyncLock.
executor:
js_test:
diff --git a/jstests/core/drop2.js b/jstests/core/drop2.js
new file mode 100644
index 00000000000..54f6b8b78ab
--- /dev/null
+++ b/jstests/core/drop2.js
@@ -0,0 +1,57 @@
+var coll = db.jstests_drop2;
+coll.drop();
+
+function debug(x) {
+ printjson(x);
+}
+
+coll.save({});
+
+function getOpId(drop) {
+ var inProg = db.currentOp().inprog;
+ debug(inProg);
+ for (var id in inProg) {
+ var op = inProg[id];
+ if (drop) {
+ if (op.query && op.query.drop && op.query.drop == coll.getName()) {
+ return op.opid;
+ }
+ } else {
+ if (op.query && op.query.query && op.query.query.$where && op.ns == (coll + "")) {
+ return op.opid;
+ }
+ }
+ }
+ return null;
+}
+
+var awaitCount = startParallelShell(
+ "print(\"Count thread started\");" + "db.getMongo().getCollection(\"" + (coll + "") + "\")" +
+ ".count( { $where: function() {" + "while( 1 ) { sleep( 1 ); } } } );" +
+ "print(\"Count thread terminating\");");
+countOpId = null;
+assert.soon(function() {
+ countOpId = getOpId(false);
+ return countOpId;
+});
+
+var awaitDrop =
+ startParallelShell("print(\"Drop thread started\");" + "print(\"drop result: \" + " +
+ "db.getMongo().getCollection(\"" + (coll + "") + "\")" + ".drop() );" +
+ "print(\"Drop thread terminating\")");
+dropOpId = null;
+assert.soon(function() {
+ dropOpId = getOpId(true);
+ return dropOpId;
+});
+
+db.killOp(dropOpId);
+db.killOp(countOpId);
+
+var exitCode = awaitCount({checkExitSuccess: false});
+assert.neq(0, exitCode, "expected shell to exit abnormally due to JS execution being terminated");
+
+// The drop operation may or may not have been killed.
+awaitDrop({checkExitSuccess: false});
+
+coll.drop(); // in SERVER-1818, this fails
diff --git a/jstests/core/killop_drop_collection.js b/jstests/core/killop_drop_collection.js
deleted file mode 100644
index 94d7d560dd3..00000000000
--- a/jstests/core/killop_drop_collection.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * A killOp command issued against a collection drop should not interfere with the drop and allow it
- * to complete. Interrupting a collection drop could leave the database in an inconsistent state.
- * This test confirms that killOp won't interrupt a collection drop, and that the drop occurs
- * successfully.
- */
-(function() {
- "use strict";
-
- const collectionName = "killop_drop";
- let collection = db.getCollection(collectionName);
- collection.drop();
- assert.writeOK(collection.insert({x: 1}));
-
- // Attempt to fsyncLock the database, aborting early if the storage engine doesn't support it.
- const storageEngine = jsTest.options().storageEngine;
- let fsyncRes = db.fsyncLock();
- if (!fsyncRes.ok) {
- assert.commandFailedWithCode(fsyncRes, ErrorCodes.CommandNotSupported);
- jsTest.log("Skipping test on storage engine " + storageEngine +
- ", which does not support fsyncLock.");
- return;
- }
-
- // Kick off a drop on the collection.
- const useDefaultPort = null;
- const noConnect = false;
- let awaitDropCommand = startParallelShell(function() {
- assert.commandWorked(db.getSiblingDB("test").runCommand({drop: "killop_drop"}));
- }, useDefaultPort, noConnect);
-
- // Wait for the drop operation to appear in the db.currentOp() output.
- let dropCommandOpId = null;
- assert.soon(function() {
- let dropOpsInProgress =
- db.currentOp().inprog.filter(op => op.query && op.query.drop === collection.getName());
- if (dropOpsInProgress.length > 0) {
- dropCommandOpId = dropOpsInProgress[0].opid;
- }
- return dropCommandOpId;
- });
-
- // Issue a killOp for the drop command, then unlock the server. We expect that the drop
- // operation was *not* killed, and that the collection was dropped successfully.
- assert.commandWorked(db.killOp(dropCommandOpId));
- let unlockRes = assert.commandWorked(db.fsyncUnlock());
- assert.eq(0,
- unlockRes.lockCount,
- "Expected the number of fsyncLocks to be zero after issuing fsyncUnlock");
- awaitDropCommand();
-
- // Ensure that the collection has been dropped.
- assert(!db.getCollectionNames().includes(collectionName),
- "Expected collection to not appear in listCollections output after being dropped");
-}());
diff --git a/jstests/libs/parallelTester.js b/jstests/libs/parallelTester.js
index ed55078934b..0126bfad9c3 100644
--- a/jstests/libs/parallelTester.js
+++ b/jstests/libs/parallelTester.js
@@ -139,6 +139,7 @@ if (typeof _threadInject != "undefined") {
"killop.js",
"run_program1.js",
"notablescan.js",
+ "drop2.js",
"dropdb_race.js",
"fsync2.js", // May be placed in serialTestsArr once SERVER-4243 is fixed.
"bench_test1.js",
@@ -169,7 +170,6 @@ if (typeof _threadInject != "undefined") {
// These tests use fsyncLock.
parallelFilesDir + "/fsync.js",
parallelFilesDir + "/currentop.js",
- parallelFilesDir + "/killop_drop_collection.js",
// These tests expect the profiler to be on or off at specific points
// during the test run.