diff options
author | Maria van Keulen <maria.vankeulen@mongodb.com> | 2019-10-10 22:05:51 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-10 22:05:51 +0000 |
commit | dd819eb95636f47f13638259208ae8a69e48ded7 (patch) | |
tree | ce42f99d086105373cf2df7c74740a910279fad2 /jstests | |
parent | de724d3d8a82667ac9da97c39abf0b9d9728cba4 (diff) | |
download | mongo-dd819eb95636f47f13638259208ae8a69e48ded7.tar.gz |
SERVER-43322 Add tunable oplog stone sizes and track truncation speeds
(cherry picked from commit 294a8f68615710b47936d5ee42439d01538ac746)
SERVER-43322 Disallow oplog_sampling.js on inMemory storage enigne
(cherry picked from commit b35dd89515473c97a87b3c06897e8a7ab51c93cc)
This backport was not a straightforward cherry-pick due to SERVER-40168
existing in master and not v4.2.
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/replsets/oplog_rollover.js | 8 | ||||
-rw-r--r-- | jstests/replsets/oplog_sampling.js | 41 |
2 files changed, 49 insertions, 0 deletions
diff --git a/jstests/replsets/oplog_rollover.js b/jstests/replsets/oplog_rollover.js index b9a08bbb80e..5199a1802fc 100644 --- a/jstests/replsets/oplog_rollover.js +++ b/jstests/replsets/oplog_rollover.js @@ -104,6 +104,14 @@ function doTest(storageEngine) { assert.soon(() => { return numInsertOplogEntry(secondaryOplog) === 2; }, "Timeout waiting for oplog to roll over on secondary"); + + if (jsTest.options().storageEngine == "wiredTiger") { + const res = primary.getDB("test").runCommand({serverStatus: 1}); + assert.commandWorked(res); + assert.eq(res.oplogTruncation.truncateCount, 1, tojson(res.oplogTruncation)); + assert.gt( + res.oplogTruncation.totalTimeTruncatingMicros, 0, tojson(res.oplogTruncation)); + } } else { // Only test that oplog truncation will eventually happen. let numInserted = 2; diff --git a/jstests/replsets/oplog_sampling.js b/jstests/replsets/oplog_sampling.js new file mode 100644 index 00000000000..3407b1826c9 --- /dev/null +++ b/jstests/replsets/oplog_sampling.js @@ -0,0 +1,41 @@ +/** + * Ensure serverStatus reports the total time spent sampling the oplog for all storage engines that + * support OplogStones. + * @tags: [ requires_wiredtiger, requires_persistence ] + */ +(function() { +"use strict"; + +// Force oplog sampling to occur on start up for small numbers of oplog inserts. +const replSet = new ReplSetTest( + {nodes: 1, nodeOptions: {setParameter: {"maxOplogTruncationPointsDuringStartup": 10}}}); +replSet.startSet(); +replSet.initiate(); + +let coll = replSet.getPrimary().getDB("test").getCollection("testcoll"); + +let res = replSet.getPrimary().getDB("test").serverStatus(); +assert.commandWorked(res); + +// Small (or empty) oplogs should be processed by scanning. +assert.gt(res.oplogTruncation.totalTimeProcessingMicros, 0); +assert.eq(res.oplogTruncation.processingMethod, "scanning"); + +// Insert enough documents to force oplog sampling to occur on the following start up. +const maxOplogDocsForScanning = 2000; +for (let i = 0; i < maxOplogDocsForScanning + 1; i++) { + assert.commandWorked(coll.insert({m: 1 + i})); +} + +// Restart replica set to load entries from the oplog for sampling. +replSet.stopSet(null /* signal */, true /* forRestart */); +replSet.startSet({restart: true}); + +res = replSet.getPrimary().getDB("test").serverStatus(); +assert.commandWorked(res); + +assert.gt(res.oplogTruncation.totalTimeProcessingMicros, 0); +assert.eq(res.oplogTruncation.processingMethod, "sampling"); + +replSet.stopSet(); +})(); |