diff options
author | Benety Goh <benety@mongodb.com> | 2020-01-08 14:05:59 +0000 |
---|---|---|
committer | A. Jesse Jiryu Davis <jesse@mongodb.com> | 2020-01-27 15:38:00 -0500 |
commit | 7ab04731ab63f62f5e06d6007795779a0056e36b (patch) | |
tree | fd65858f55b2d18fea5fde9f8920a862a8494204 /jstests | |
parent | c98f329d9d89d9e1507442751a92cc86cef29b0d (diff) | |
download | mongo-7ab04731ab63f62f5e06d6007795779a0056e36b.tar.gz |
SERVER-44821 accessing db.system.profile and currentOp storage stats should not conflict with slow oplog application
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/noPassthrough/currentop_secondary_slow_op.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/jstests/noPassthrough/currentop_secondary_slow_op.js b/jstests/noPassthrough/currentop_secondary_slow_op.js new file mode 100644 index 00000000000..66e83520056 --- /dev/null +++ b/jstests/noPassthrough/currentop_secondary_slow_op.js @@ -0,0 +1,64 @@ +/** + * Confirms slow currentOp logging does not conflict with applying an oplog batch. + * @tags: [requires_replication] + */ +(function() { +"use strict"; + +const rst = new ReplSetTest({ + nodes: [ + {}, + { + // Disallow elections on secondary. + rsConfig: { + priority: 0, + votes: 0, + }, + slowms: 30000, // Don't log slow operations on secondary. + }, + ] +}); +const nodes = rst.startSet(); +rst.initiate(); + +const primary = rst.getPrimary(); +const testDB = primary.getDB('test'); +const coll = testDB.getCollection('test'); + +assert.commandWorked(coll.insert({_id: 'a'})); + +const secondary = rst.getSecondary(); +const secondaryDB = secondary.getDB(testDB.getName()); +assert.commandWorked(secondaryDB.adminCommand({ + configureFailPoint: 'hangAfterCollectionInserts', + mode: 'alwaysOn', + data: { + collectionNS: coll.getFullName(), + first_id: 'b', + }, +})); + +try { + assert.commandWorked(coll.insert({_id: 'b'})); + checkLog.contains(secondary, + 'hangAfterCollectionInserts fail point enabled for ' + coll.getFullName()); + + jsTestLog('Running currentOp() with slow operation logging.'); + // Lower slowms to make currentOp() log slow operation while the secondary is procesing the + // commitIndexBuild oplog entry during oplog application. + // Use admin db on secondary to avoid lock conflict with inserts in test db. + const secondaryAdminDB = secondaryDB.getSiblingDB('admin'); + const profileResult = assert.commandWorked(secondaryAdminDB.setProfilingLevel(0, {slowms: -1})); + jsTestLog('Configured profiling to always log slow ops: ' + tojson(profileResult)); + const currentOpResult = assert.commandWorked(secondaryAdminDB.currentOp()); + jsTestLog('currentOp() with slow operation logging: ' + tojson(currentOpResult)); + assert.commandWorked( + secondaryAdminDB.setProfilingLevel(profileResult.was, {slowms: profileResult.slowms})); + jsTestLog('Completed currentOp() with slow operation logging.'); +} finally { + assert.commandWorked( + secondaryDB.adminCommand({configureFailPoint: 'hangAfterCollectionInserts', mode: 'off'})); +} + +rst.stopSet(); +})(); |