diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2018-06-06 14:28:22 -0400 |
---|---|---|
committer | Tess Avitabile <tess.avitabile@mongodb.com> | 2018-06-08 13:54:55 -0400 |
commit | c0273c0a89e73ecfd7848fd4906a8e3c2d5886b9 (patch) | |
tree | 85c45cd7d61b0bf8fa443b69e5d1755506352e9d /jstests/core/txns/kill_transaction_cursors_after_commit.js | |
parent | c5152ff1761014ee1eaf8339e8ca6c80f59c5027 (diff) | |
download | mongo-c0273c0a89e73ecfd7848fd4906a8e3c2d5886b9.tar.gz |
SERVER-35217 Do not kill associated client cursors when transaction ends
Diffstat (limited to 'jstests/core/txns/kill_transaction_cursors_after_commit.js')
-rw-r--r-- | jstests/core/txns/kill_transaction_cursors_after_commit.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/jstests/core/txns/kill_transaction_cursors_after_commit.js b/jstests/core/txns/kill_transaction_cursors_after_commit.js new file mode 100644 index 00000000000..50aa93b749f --- /dev/null +++ b/jstests/core/txns/kill_transaction_cursors_after_commit.js @@ -0,0 +1,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(); + 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)); + session.commitTransaction(); + 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)); + session.commitTransaction(); + assert.commandWorked(testDB.runCommand({killCursors: collName, cursors: [res.cursor.id]})); + + session.endSession(); +}()); |