blob: 003158c3e5207d877a19fad6964193ba62b6a4a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// Tests that cursors created in transactions may be killed outside of the transaction.
// @tags: [uses_transactions]
(function() {
"use strict";
const dbName = "test";
const collName = "kill_transaction_cursors";
const testDB = db.getSiblingDB(dbName);
const session = db.getMongo().startSession({causalConsistency: false});
const sessionDb = session.getDatabase(dbName);
const sessionColl = sessionDb[collName];
sessionColl.drop({writeConcern: {w: "majority"}});
for (let i = 0; i < 4; ++i) {
assert.commandWorked(sessionColl.insert({_id: i}));
}
jsTest.log("Test that cursors created in transactions may be kill outside of the transaction.");
session.startTransaction();
let res = assert.commandWorked(sessionDb.runCommand({find: collName, batchSize: 2}));
assert(res.hasOwnProperty("cursor"), tojson(res));
assert(res.cursor.hasOwnProperty("id"), tojson(res));
assert.commandWorked(session.commitTransaction_forTesting());
assert.commandWorked(sessionDb.runCommand({killCursors: collName, cursors: [res.cursor.id]}));
jsTest.log("Test that cursors created in transactions may be kill outside of the session.");
session.startTransaction();
res = assert.commandWorked(sessionDb.runCommand({find: collName, batchSize: 2}));
assert(res.hasOwnProperty("cursor"), tojson(res));
assert(res.cursor.hasOwnProperty("id"), tojson(res));
assert.commandWorked(session.commitTransaction_forTesting());
assert.commandWorked(testDB.runCommand({killCursors: collName, cursors: [res.cursor.id]}));
session.endSession();
}());
|