summaryrefslogtreecommitdiff
path: root/jstests/replsets/session_cache_refresh_write_error_fail.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/replsets/session_cache_refresh_write_error_fail.js')
-rw-r--r--jstests/replsets/session_cache_refresh_write_error_fail.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/jstests/replsets/session_cache_refresh_write_error_fail.js b/jstests/replsets/session_cache_refresh_write_error_fail.js
new file mode 100644
index 00000000000..8a2749b0fac
--- /dev/null
+++ b/jstests/replsets/session_cache_refresh_write_error_fail.js
@@ -0,0 +1,33 @@
+/**
+ * Test that write errors resulting as part of refreshing logical session do not kill open cursors.
+ */
+(function() {
+"use strict";
+
+load("jstests/libs/fail_point_util.js");
+
+const rst = new ReplSetTest({nodes: 1});
+
+rst.startSet();
+rst.initiate();
+
+const db = rst.getPrimary().getDB("test");
+const fp = configureFailPoint(db, "failAllUpdates");
+const collection = db.getCollection("mycoll");
+const sessionDb = db.getMongo().startSession().getDatabase(db.getName());
+const sessionCollection = sessionDb.getCollection(collection.getName());
+
+assert.commandWorked(sessionCollection.insert(Array.from({length: 5}, (_, i) => ({_id: i}))));
+
+const res = assert.commandWorked(sessionCollection.runCommand("find", {batchSize: 2}));
+
+assert.commandFailedWithCode(db.adminCommand({refreshLogicalSessionCacheNow: 1}),
+ ErrorCodes.InternalError);
+
+assert.commandWorked(
+ sessionDb.runCommand({getMore: res.cursor.id, collection: sessionCollection.getName()}));
+
+fp.off();
+
+rst.stopSet();
+})();