diff options
Diffstat (limited to 'jstests/core/txns/kill_transaction_cursors_after_commit.js')
-rw-r--r-- | jstests/core/txns/kill_transaction_cursors_after_commit.js | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/jstests/core/txns/kill_transaction_cursors_after_commit.js b/jstests/core/txns/kill_transaction_cursors_after_commit.js index 003158c3e52..0910b6fb1b7 100644 --- a/jstests/core/txns/kill_transaction_cursors_after_commit.js +++ b/jstests/core/txns/kill_transaction_cursors_after_commit.js @@ -1,35 +1,35 @@ // Tests that cursors created in transactions may be killed outside of the transaction. // @tags: [uses_transactions] (function() { - "use strict"; +"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]; +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})); - } +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 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]})); +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(); +session.endSession(); }()); |