diff options
Diffstat (limited to 'jstests/concurrency/fsm_libs/worker_thread.js')
-rw-r--r-- | jstests/concurrency/fsm_libs/worker_thread.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/jstests/concurrency/fsm_libs/worker_thread.js b/jstests/concurrency/fsm_libs/worker_thread.js index 3b2ec6e8571..806d04f20cb 100644 --- a/jstests/concurrency/fsm_libs/worker_thread.js +++ b/jstests/concurrency/fsm_libs/worker_thread.js @@ -72,7 +72,21 @@ var workerThread = (function() { delete args.sessionOptions.initialOperationTime; } - const session = new Mongo(connectionString).startSession(args.sessionOptions); + const mongo = new Mongo(connectionString); + + const session = mongo.startSession(args.sessionOptions); + const readPreference = session.getOptions().getReadPreference(); + if (readPreference && readPreference.mode === 'secondary') { + // Unset the explicit read preference so set_read_preference_secondary.js can do + // the right thing based on the DB. + session.getOptions().setReadPreference(undefined); + + // We load() set_read_preference_secondary.js in order to avoid running + // commands against the "admin" and "config" databases via mongos with + // readPreference={mode: "secondary"} when there's only a single node in + // the CSRS. + load('jstests/libs/override_methods/set_read_preference_secondary.js'); + } if (typeof initialClusterTime !== 'undefined') { session.advanceClusterTime(initialClusterTime); |