summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Russotto <matthew.russotto@10gen.com>2020-07-31 16:34:50 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-04-08 15:10:34 +0000
commit19dbf6e9b910c38a4d3de34a5000585456081b28 (patch)
tree2a1dc330ff9181634e00c0e7512e3bac1f4106e1
parent3e2fc6c840201c118e5359bd0f61bacf0d438635 (diff)
downloadmongo-19dbf6e9b910c38a4d3de34a5000585456081b28.tar.gz
SERVER-50060 Make oplog_slow_sampling_logging.js tolerant to small changes in the clock. Also make it faster by using batch operations.
(cherry picked from commit ce617fa26c59551e93f3950353352ecabee38b44)
-rw-r--r--jstests/replsets/oplog_slow_sampling_logging.js24
1 files changed, 20 insertions, 4 deletions
diff --git a/jstests/replsets/oplog_slow_sampling_logging.js b/jstests/replsets/oplog_slow_sampling_logging.js
index b679c3b20e4..91c0d46716b 100644
--- a/jstests/replsets/oplog_slow_sampling_logging.js
+++ b/jstests/replsets/oplog_slow_sampling_logging.js
@@ -6,9 +6,16 @@
(function() {
"use strict";
-const kOplogDocs = 45000;
+const kOplogDocs = 47500;
// kNumOplogSamples is derived from the number of oplog entries above.
-const kNumOplogSamples = 15;
+// Formula is kRandomSamplesPerStone * numRecords / estRecordsPerStone, where
+// kRandomSamplesPerStone = 10
+// numRecords = kOplogDocs + some small number of bookkeeping records
+// estRecordsPerStone = (16MB / average oplog record size), empirically about 28700 records.
+// The number of samples is picked to NOT be divisible by kLoggingIntervalSeconds so we can
+// safely miss a logging interval without failing; this can sometimes happen due to clock
+// adjustment.
+const kNumOplogSamples = 16;
const kOplogSampleReadDelay = 1;
const kLoggingIntervalSeconds = 3;
@@ -32,8 +39,17 @@ replSet.initiate();
let coll = replSet.getPrimary().getDB(testDB).getCollection("testcoll");
// Insert enough documents to force kNumOplogSamples to be taken on the following start up.
-for (let i = 0; i < kOplogDocs; i++) {
- assert.commandWorked(coll.insert({m: 1 + i}));
+let docsRemaining = kOplogDocs;
+let docsDone = 0;
+while (docsRemaining) {
+ let batchDocs = docsRemaining > 1000 ? 1000 : docsRemaining;
+ let bulk = coll.initializeUnorderedBulkOp();
+ for (let i = 0; i < batchDocs; i++) {
+ bulk.insert({m: 1 + i + docsDone});
+ }
+ assert.commandWorked(bulk.execute());
+ docsRemaining -= batchDocs;
+ docsDone += batchDocs;
}
// Restart replica set to load entries from the oplog for sampling.