summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpencer Jackson <spencer.jackson@mongodb.com>2016-08-02 17:43:23 -0400
committerSpencer Jackson <spencer.jackson@mongodb.com>2016-08-19 16:40:11 -0400
commitcad4fd77ac49d5a93f788a333511286276341cd5 (patch)
treef22032c9050c511930165b3d8a6067953e82c39e
parent1d310d62e03d722e993e9428677044554fa2adb6 (diff)
downloadmongo-cad4fd77ac49d5a93f788a333511286276341cd5.tar.gz
SERVER-25416: Use failpoint in killop_own_ops.js
(cherry picked from commit 8741e54c896456ccbcb65ae4d377e40b699c225c)
-rw-r--r--jstests/auth/killop_own_ops.js41
-rw-r--r--src/mongo/db/query/query_yield.cpp3
2 files changed, 30 insertions, 14 deletions
diff --git a/jstests/auth/killop_own_ops.js b/jstests/auth/killop_own_ops.js
index b4dc9085263..d412e31c8ce 100644
--- a/jstests/auth/killop_own_ops.js
+++ b/jstests/auth/killop_own_ops.js
@@ -24,8 +24,13 @@
privileges: [{resource: {cluster: true}, actions: ['inprog', 'killop']}]
});
db.createUser({user: 'opAdmin', pwd: 'opAdmin', roles: [{role: 'opAdmin', db: 'admin'}]});
+
var t = db.jstests_killop;
t.save({x: 1});
+
+ assert.commandWorked(
+ db.adminCommand({setParameter: 1, internalQueryExecYieldIterations: 1}));
+
admin.logout();
/**
@@ -41,8 +46,8 @@
// active, which it may not be in our polling cycle - particularly b/c we sleep
// every
// second in both the query and the assert
- if ((o.active || o.waitingForLock) && o.query && o.query.query &&
- o.query.query.$where && o.query.count == "jstests_killop") {
+ if ((o.active || o.waitingForLock) && o.query && o.query &&
+ o.query.find === "jstests_killop" && o.query.comment === "kill_own_ops") {
print("OP: " + tojson(o));
ids.push(o.opid);
}
@@ -50,12 +55,14 @@
return ids;
}
- var countWithWhereOp =
- 'db = db.getSiblingDB("foo"); db.auth("reader", "reader"); db.jstests_killop.count({ $where: function() { while (1) { sleep(500); } } });';
+ var queryAsReader =
+ 'db = db.getSiblingDB("foo"); db.auth("reader", "reader"); db.jstests_killop.find().comment("kill_own_ops").toArray()';
+ jsTestLog("Starting long-running operation");
db.auth('reader', 'reader');
- jsTestLog("Starting long-running $where operation");
- var s1 = startParallelShell(countWithWhereOp, m.port);
+ assert.commandWorked(
+ db.adminCommand({configureFailPoint: "setYieldAllLocksHang", mode: "alwaysOn"}));
+ var s1 = startParallelShell(queryAsReader, m.port);
jsTestLog("Finding ops in currentOp() output");
var o = [];
@@ -75,9 +82,8 @@
db.logout();
db.auth('otherReader', 'otherReader');
assert.eq([], ops());
- db.killOp(o[0]);
+ assert.commandFailed(db.killOp(o[0]));
db.logout();
- sleep(10);
db.auth('reader', 'reader');
assert.eq(1, ops().length);
db.logout();
@@ -85,20 +91,25 @@
jsTestLog("Checking that originating user can kill operation");
var start = new Date();
db.auth('reader', 'reader');
- db.killOp(o[0]);
+ assert.commandWorked(db.killOp(o[0]));
+ assert.commandWorked(
+ db.adminCommand({configureFailPoint: "setYieldAllLocksHang", mode: "off"}));
jsTestLog("Waiting for ops to terminate");
var exitCode = s1({checkExitSuccess: false});
- assert.neq(
- 0, exitCode, "expected shell to exit abnormally due to JS execution being terminated");
+ assert.neq(0,
+ exitCode,
+ "expected shell to exit abnormally due to operation execution being terminated");
// don't want to pass if timeout killed the js function.
var end = new Date();
var diff = end - start;
assert.lt(diff, 30000, "Start: " + start + "; end: " + end + "; diff: " + diff);
- jsTestLog("Starting a second long-running $where operation");
- var s2 = startParallelShell(countWithWhereOp, m.port);
+ jsTestLog("Starting a second long-running operation");
+ assert.commandWorked(
+ db.adminCommand({configureFailPoint: "setYieldAllLocksHang", mode: "alwaysOn"}));
+ var s2 = startParallelShell(queryAsReader, m.port);
jsTestLog("Finding ops in currentOp() output");
var o2 = [];
assert.soon(
@@ -125,7 +136,9 @@
jsTestLog("Checking that an administrative user can kill others' operations");
var start = new Date();
- db.killOp(o2[0]);
+ assert.commandWorked(db.killOp(o2[0]));
+ assert.commandWorked(
+ db.adminCommand({configureFailPoint: "setYieldAllLocksHang", mode: "off"}));
jsTestLog("Waiting for ops to terminate");
var exitCode = s2({checkExitSuccess: false});
assert.neq(
diff --git a/src/mongo/db/query/query_yield.cpp b/src/mongo/db/query/query_yield.cpp
index eed020fd286..a4fbd5cca12 100644
--- a/src/mongo/db/query/query_yield.cpp
+++ b/src/mongo/db/query/query_yield.cpp
@@ -40,6 +40,7 @@
namespace mongo {
namespace {
+MONGO_FP_DECLARE(setYieldAllLocksHang);
MONGO_FP_DECLARE(setYieldAllLocksWait);
} // namespace
@@ -71,6 +72,8 @@ void QueryYield::yieldAllLocks(OperationContext* txn,
// locks). If we are yielding, we are at a safe place to do so.
txn->recoveryUnit()->abandonSnapshot();
+ MONGO_FAIL_POINT_PAUSE_WHILE_SET(setYieldAllLocksHang);
+
MONGO_FAIL_POINT_BLOCK(setYieldAllLocksWait, customWait) {
const BSONObj& data = customWait.getData();
BSONElement customWaitNS = data["namespace"];