diff options
author | Lingzhi Deng <lingzhi.deng@mongodb.com> | 2020-04-30 10:44:34 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-14 00:39:16 +0000 |
commit | baf179e4b7059dcff2b802a4af689afc342601c6 (patch) | |
tree | a5db4f784705d441187e976b90c09a6a0d3e6c2a /jstests/noPassthrough/readConcern_atClusterTime.js | |
parent | 0314de03de967fb5225e4854da7cf03d6b33fc05 (diff) | |
download | mongo-baf179e4b7059dcff2b802a4af689afc342601c6.tar.gz |
SERVER-47779: Clearer error message when both “atClusterTime” and “afterClusterTime” are specified
Diffstat (limited to 'jstests/noPassthrough/readConcern_atClusterTime.js')
-rw-r--r-- | jstests/noPassthrough/readConcern_atClusterTime.js | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/jstests/noPassthrough/readConcern_atClusterTime.js b/jstests/noPassthrough/readConcern_atClusterTime.js index 9e756c488da..2a666955dc1 100644 --- a/jstests/noPassthrough/readConcern_atClusterTime.js +++ b/jstests/noPassthrough/readConcern_atClusterTime.js @@ -35,8 +35,8 @@ if (!testDB.serverStatus().storageEngine.supportsSnapshotReadConcern) { return; } -const session = testDB.getMongo().startSession({causalConsistency: false}); -const sessionDb = session.getDatabase(dbName); +let session = testDB.getMongo().startSession({causalConsistency: false}); +let sessionDb = session.getDatabase(dbName); const clusterTime = _getClusterTime(rst); @@ -104,8 +104,21 @@ session.startTransaction( {readConcern: {level: "snapshot", atClusterTime: clusterTime, afterClusterTime: clusterTime}}); assert.commandFailedWithCode(sessionDb.runCommand({find: collName}), ErrorCodes.InvalidOptions); assert.commandFailedWithCode(session.abortTransaction_forTesting(), ErrorCodes.NoSuchTransaction); - session.endSession(); + +// 'atClusterTime' cannot be used within causally consistent sessions. +session = testDB.getMongo().startSession(); +sessionDb = session.getDatabase(dbName); +// Perform a local read to establish an 'afterClusterTime' for the session. +assert.commandWorked(sessionDb.runCommand({find: collName})); +assert(assert + .commandFailedWithCode( + sessionDb.runCommand( + {find: collName, readConcern: {level: "snapshot", atClusterTime: clusterTime}}), + ErrorCodes.InvalidOptions) + .errmsg.includes("Specifying a timestamp for readConcern snapshot in a causally " + + "consistent session is not allowed")); + rst.stopSet(); // readConcern with 'atClusterTime' should succeed regardless of value of 'enableTestCommands'. |