summaryrefslogtreecommitdiff
path: root/jstests/replsets/read_at_cluster_time_outside_transactions.js
diff options
context:
space:
mode:
authorLouis Williams <louis.williams@mongodb.com>2020-06-10 14:13:03 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-11 15:24:45 +0000
commit0f707044926e0cec422294520f9e42d777818b1f (patch)
treeb3d827a6f0ce017c9eeaaa302a43e7eefef2115f /jstests/replsets/read_at_cluster_time_outside_transactions.js
parent33d4a16dec74c49d05eefacf2d965fab23073195 (diff)
downloadmongo-0f707044926e0cec422294520f9e42d777818b1f.tar.gz
SERVER-48301 find command should reject $_internalReadAtClusterTime values less than afterClusterTime
Diffstat (limited to 'jstests/replsets/read_at_cluster_time_outside_transactions.js')
-rw-r--r--jstests/replsets/read_at_cluster_time_outside_transactions.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/jstests/replsets/read_at_cluster_time_outside_transactions.js b/jstests/replsets/read_at_cluster_time_outside_transactions.js
index e75bf2656e5..252d347e24e 100644
--- a/jstests/replsets/read_at_cluster_time_outside_transactions.js
+++ b/jstests/replsets/read_at_cluster_time_outside_transactions.js
@@ -2,7 +2,11 @@
* Tests that the "find" and "dbHash" commands support reading at a Timestamp by using the
* $_internalReadAtClusterTime option.
*
- * @tags: [requires_document_locking, uses_transactions]
+ * @tags: [
+ * requires_document_locking,
+ * requires_fcv_46,
+ * uses_transactions,
+ * ]
*/
(function() {
"use strict";
@@ -31,6 +35,9 @@ rst.nodes.forEach(conn => {
// insert.
assert.commandWorked(collection.insert({_id: 1, comment: "should be seen by find command"}));
assert.commandWorked(collection.insert({_id: 3, comment: "should be seen by find command"}));
+
+const earlierClusterTime = db.getSession().getOperationTime();
+
assert.commandWorked(collection.insert({_id: 5, comment: "should be seen by getMore command"}));
const clusterTime = db.getSession().getOperationTime();
@@ -116,6 +123,13 @@ assert.commandFailedWithCode(db.runCommand({
}),
ErrorCodes.InvalidOptions);
+// 'find' may not read at a cluster time that is earlier than an 'afterClusterTime' readConcern.
+assert.commandFailedWithCode(collection.runCommand("find", {
+ $_internalReadAtClusterTime: earlierClusterTime,
+ readConcern: {afterClusterTime: clusterTime}
+}),
+ ErrorCodes.InvalidOptions);
+
// $_internalReadAtClusterTime is not supported in transactions.
const session = primary.startSession();
const sessionDB = session.getDatabase("test");