mongo/jstests/replsets/session_cache_refresh_write_error_fail.js
Zac 591928c619 SERVER-108478 JS formatted by prettier and remove clang-format (#39656)
GitOrigin-RevId: 6c8f6aded47f260aa4f7c231b17dae3302cb1e04
2025-08-21 17:27:09 +00:00

29 lines
1.0 KiB
JavaScript

/**
* Test that write errors resulting as part of refreshing logical session do not kill open cursors.
*/
import {configureFailPoint} from "jstests/libs/fail_point_util.js";
import {ReplSetTest} from "jstests/libs/replsettest.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();