summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Suarez <kyle.suarez@mongodb.com>2017-01-20 11:27:56 -0500
committerKyle Suarez <kyle.suarez@mongodb.com>2017-01-20 11:34:11 -0500
commitd4e459b768349936ce72bb53ec056bc5918119f1 (patch)
treeecc0913c9b1f22c66db1ec025dbc38c02df42e00
parent153d6473f705afbd18e151c437f91b5fbc733370 (diff)
downloadmongo-d4e459b768349936ce72bb53ec056bc5918119f1.tar.gz
SERVER-25286 rewrite drop2.js to not depend on count scan yield behavior
Tweaks killop_drop_collection.js to not use ES6 features and the new response format of fsyncUnlock. (cherry picked from commit 703678d473121b6402df10c21060241096ee2722) Conflicts: buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml
-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.js54
-rw-r--r--jstests/libs/parallelTester.js2
5 files changed, 57 insertions, 58 deletions
diff --git a/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml b/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml
index 32ad9399d63..e88028fcb41 100644
--- a/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/sharded_collections_jscore_passthrough.yml
@@ -68,6 +68,7 @@ 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 a1758adb65c..db5e043b209 100644
--- a/buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml
+++ b/buildscripts/resmokeconfig/suites/sharding_jscore_passthrough.yml
@@ -42,6 +42,7 @@ 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
deleted file mode 100644
index 54f6b8b78ab..00000000000
--- a/jstests/core/drop2.js
+++ /dev/null
@@ -1,57 +0,0 @@
-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
new file mode 100644
index 00000000000..7138ee8eda6
--- /dev/null
+++ b/jstests/core/killop_drop_collection.js
@@ -0,0 +1,54 @@
+/**
+ * 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";
+
+ var collectionName = "killop_drop";
+ var 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.
+ var storageEngine = jsTest.options().storageEngine;
+ var 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.
+ var useDefaultPort = null;
+ var noConnect = false;
+ var 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.
+ var dropCommandOpId = null;
+ assert.soon(function() {
+ var dropOpsInProgress = db.currentOp().inprog.filter(function(op) {
+ return 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));
+ assert.commandWorked(db.fsyncUnlock());
+ awaitDropCommand();
+
+ // Ensure that the collection has been dropped.
+ assert.eq(-1,
+ db.getCollectionNames().indexOf(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 0126bfad9c3..ed55078934b 100644
--- a/jstests/libs/parallelTester.js
+++ b/jstests/libs/parallelTester.js
@@ -139,7 +139,6 @@ 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",
@@ -170,6 +169,7 @@ 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.