diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2020-12-17 19:55:15 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-12-18 18:02:40 +0000 |
commit | 3417215850d7a577452552499ea55d1872199d74 (patch) | |
tree | 3df6156281668ebb38189e3a409c3d065b866f4a /jstests | |
parent | ee2007a2855cf27aa54db1850dedfd62682b89aa (diff) | |
download | mongo-3417215850d7a577452552499ea55d1872199d74.tar.gz |
SERVER-52950 recoverFromOplogAsStandalone mode must not start oplog truncater thread
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/noPassthrough/check_for_oplog_cap_maintainer_thread.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/jstests/noPassthrough/check_for_oplog_cap_maintainer_thread.js b/jstests/noPassthrough/check_for_oplog_cap_maintainer_thread.js new file mode 100644 index 00000000000..ae5588c20f6 --- /dev/null +++ b/jstests/noPassthrough/check_for_oplog_cap_maintainer_thread.js @@ -0,0 +1,58 @@ +/** + * Checks that the oplog cap maintainer thread is started and the oplog stones calculation is + * performed under normal startup circumstances. Both of these operations should not be done when + * starting up with any of the following modes: + * - readonly + * - repair + * - recoverFromOplogAsStandalone + * + * @tags: [requires_replication, requires_persistence] + */ +(function() { +"use strict"; + +// Verify that the oplog cap maintainer thread is running under normal circumstances. +jsTestLog("Testing single node replica set mode"); +const rst = new ReplSetTest({nodes: 1, nodeOptions: {setParameter: {logLevel: 1}}}); +rst.startSet(); +rst.initiate(); + +const primary = rst.getPrimary(); + +checkLog.contains(primary, "OplogTruncaterThread started"); +checkLog.contains(primary, "WiredTiger record store oplog processing took"); + +rst.stopSet(/*signal=*/null, /*forRestart=*/true); + +// A subset of startup options prevent the oplog cap maintainer thread from being started. These +// startup options are currently limited to readOnly, recoverFromOplogAsStandalone and repair. +function verifyOplogCapMaintainerThreadNotStarted(log) { + const threadRegex = new RegExp("OplogTruncaterThread started"); + const oplogStonesRegex = new RegExp("WiredTiger record store oplog processing took"); + + assert(!threadRegex.test(log)); + assert(!oplogStonesRegex.test(log)); +} + +jsTestLog("Testing recoverFromOplogAsStandalone mode"); +clearRawMongoProgramOutput(); +let conn = MongoRunner.runMongod({ + dbpath: primary.dbpath, + noCleanData: true, + setParameter: {recoverFromOplogAsStandalone: true, logLevel: 1}, +}); +assert(conn); +MongoRunner.stopMongod(conn); +verifyOplogCapMaintainerThreadNotStarted(rawMongoProgramOutput()); + +jsTestLog("Testing repair mode"); +clearRawMongoProgramOutput(); +conn = MongoRunner.runMongod({ + dbpath: primary.dbpath, + noCleanData: true, + repair: "", + setParameter: {logLevel: 1}, +}); +assert(!conn); +verifyOplogCapMaintainerThreadNotStarted(rawMongoProgramOutput()); +}()); |