From 39dcbb3f81dfd930af02a98bf6cdb93a31be0b38 Mon Sep 17 00:00:00 2001 From: David Hatch Date: Tue, 26 Jul 2016 11:55:05 -0400 Subject: [PATCH] repo. --- repo.js | 61 +++++++++++++++++++++++++++++++++++ src/mongo/db/exec/collection_scan.cpp | 6 ++++ 2 files changed, 67 insertions(+) create mode 100644 repo.js diff --git a/repo.js b/repo.js new file mode 100644 index 0000000..e7b5265 --- /dev/null +++ b/repo.js @@ -0,0 +1,61 @@ +var coll = db.repo; +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; +} + +db.getSiblingDB('admin').runCommand({configureFailPoint: 'collectionScanYield', mode: {times: 1}}); +db.getSiblingDB('admin').runCommand( + {configureFailPoint: 'setYieldAllLocksWait', mode: {times: 2}, data: {waitForMillis: 500}}); + +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/src/mongo/db/exec/collection_scan.cpp b/src/mongo/db/exec/collection_scan.cpp index 1e1e88e..73bd644 100644 --- a/src/mongo/db/exec/collection_scan.cpp +++ b/src/mongo/db/exec/collection_scan.cpp @@ -40,12 +40,14 @@ #include "mongo/db/exec/working_set_common.h" #include "mongo/db/storage/record_fetcher.h" #include "mongo/stdx/memory.h" +#include "mongo/util/fail_point.h" #include "mongo/util/fail_point_service.h" #include "mongo/util/log.h" #include "mongo/db/client.h" // XXX-ERH namespace mongo { +MONGO_FP_DECLARE(collectionScanYield); using std::unique_ptr; using std::vector; @@ -118,6 +120,10 @@ PlanStage::StageState CollectionScan::doWork(WorkingSetID* out) { return PlanStage::NEED_TIME; } + if (MONGO_FAIL_POINT(collectionScanYield)) { + return PlanStage::NEED_YIELD; + } + if (_lastSeenId.isNull() && !_params.start.isNull()) { record = _cursor->seekExact(_params.start); } else { -- 2.8.3