summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorLingzhi Deng <lingzhi.deng@mongodb.com>2021-03-22 15:23:25 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-03-22 16:18:36 +0000
commitc45819ca1324f65a2eb0040eff1754289383711a (patch)
tree6696a51626a7be231badb8bdbb475d2d89000a8d /jstests
parent939178eb77d25dc234de03ac7d5dc98210514c7a (diff)
downloadmongo-c45819ca1324f65a2eb0040eff1754289383711a.tar.gz
SERVER-55044: Do a majority write before starting tests in read_majority_reads.js
Diffstat (limited to 'jstests')
-rw-r--r--jstests/noPassthrough/read_majority_reads.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/jstests/noPassthrough/read_majority_reads.js b/jstests/noPassthrough/read_majority_reads.js
index dc02f8c215b..a1c73cd28e3 100644
--- a/jstests/noPassthrough/read_majority_reads.js
+++ b/jstests/noPassthrough/read_majority_reads.js
@@ -189,6 +189,13 @@ replTest.initiateWithAnyNodeAsPrimary(
var mongod = replTest.getPrimary();
+// Do a majority write to wait for a valid committed snapshot before starting the test. This is
+// needed to make sure no oplog holes behind the clusterTime and all internal writes as part of the
+// server startup are committed. Otherwise, manually setting the committed snapshot to the latest
+// clusterTime using the `setCommittedSnapshot` command could result in reading ahead of the
+// all_durable.
+assert.commandWorked(mongod.getDB("test")["coll"].insert({x: 1}, {writeConcern: {w: "majority"}}));
+
(function testSingleNode() {
var db = mongod.getDB("singleNode");
runTests(db.collection, mongod);