diff options
-rw-r--r-- | jstests/core/txns/read_concerns.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/jstests/core/txns/read_concerns.js b/jstests/core/txns/read_concerns.js index 15723fe4154..83d1d5f2813 100644 --- a/jstests/core/txns/read_concerns.js +++ b/jstests/core/txns/read_concerns.js @@ -4,6 +4,8 @@ (function() { "use strict"; +load('jstests/libs/auto_retry_transaction_in_sharding.js'); + const dbName = "test"; const collName = "supported_read_concern_levels"; @@ -20,19 +22,17 @@ function runTest(level, sessionOptions, supported) { // Set up the collection. assert.commandWorked(sessionColl.insert({_id: 0}, {writeConcern: {w: "majority"}})); - if (level) { - session.startTransaction({readConcern: {level: level}}); - } else { - session.startTransaction(); - } + const txnOpts = (level ? {readConcern: {level: level}} : {}); - const res = sessionDB.runCommand({find: collName}); if (supported) { - assert.commandWorked(res, - "expected success, read concern level: " + level + - ", sessionOptions: " + tojson(sessionOptions)); - assert.commandWorked(session.commitTransaction_forTesting()); + withTxnAndAutoRetryOnMongos(session, () => { + assert.commandWorked(sessionDB.runCommand({find: collName}), + "expected success, read concern level: " + level + + ", sessionOptions: " + tojson(sessionOptions)); + }, txnOpts); } else { + session.startTransaction(txnOpts); + const res = sessionDB.runCommand({find: collName}); assert.commandFailedWithCode(res, ErrorCodes.InvalidOptions, "expected failure, read concern level: " + level + |