summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorSamy Lanka <samy.lanka@mongodb.com>2018-11-13 17:54:25 -0500
committerSamy Lanka <samy.lanka@mongodb.com>2018-11-14 15:59:19 -0500
commitc1d4e0b8e1a4c197aac2530259f78eb88fb4acd3 (patch)
tree735fff720cc1b39e7ec9382773bb5016d4e78dca /jstests
parentdd2b355042d8f64e2a10d7b9986265ba563dddd8 (diff)
downloadmongo-c1d4e0b8e1a4c197aac2530259f78eb88fb4acd3.tar.gz
SERVER-36587 Disallow the first operation in a transaction to be killCursors
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/txns/kill_cursors_in_transaction.js18
1 files changed, 6 insertions, 12 deletions
diff --git a/jstests/core/txns/kill_cursors_in_transaction.js b/jstests/core/txns/kill_cursors_in_transaction.js
index aa68cb25f73..2ca718a7e33 100644
--- a/jstests/core/txns/kill_cursors_in_transaction.js
+++ b/jstests/core/txns/kill_cursors_in_transaction.js
@@ -25,22 +25,16 @@
assert.commandWorked(sessionDb.runCommand({killCursors: collName, cursors: [res.cursor.id]}));
session.commitTransaction();
- jsTest.log("Test that the killCursors can be the first operation in a transaction.");
- // Note that it is not a requirement to support this behavior. This test is present to ensure
- // that the server does not crash or return an unhelpful error message.
-
+ jsTest.log("Test that the killCursors cannot be the first operation in a transaction.");
res = assert.commandWorked(sessionDb.runCommand({find: collName, batchSize: 2}));
assert(res.hasOwnProperty("cursor"), tojson(res));
assert(res.cursor.hasOwnProperty("id"), tojson(res));
session.startTransaction();
- assert.commandWorked(sessionDb.runCommand({killCursors: collName, cursors: [res.cursor.id]}));
-
- try {
- session.commitTransaction();
- } catch (ex) {
- assert.eq(50940, ex.code);
- print('Error (expected) returned while performing commit: ' + tojson(ex));
- }
+ assert.commandFailedWithCode(
+ sessionDb.runCommand({killCursors: collName, cursors: [res.cursor.id]}),
+ ErrorCodes.OperationNotSupportedInTransaction);
+ assert.commandFailedWithCode(session.abortTransaction_forTesting(),
+ ErrorCodes.NoSuchTransaction);
jsTest.log("killCursors must not block on locks held by the transaction in which it is run.");