diff options
author | Gregory Wlodarek <gregory.wlodarek@mongodb.com> | 2019-10-07 15:24:36 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-07 15:24:36 +0000 |
commit | add5e59c4b2a2e2229f4c08bc42daa060307e123 (patch) | |
tree | dd9b9e99b3c4af9e7b8e5b552cb1a7a398d4d171 /jstests/noPassthroughWithMongod | |
parent | db72f68739de5e01b11ce3b02e0540ef2b2bd601 (diff) | |
download | mongo-add5e59c4b2a2e2229f4c08bc42daa060307e123.tar.gz |
SERVER-43823 Fail background validation if restartCatalog runs while validate locks are yielded
Diffstat (limited to 'jstests/noPassthroughWithMongod')
-rw-r--r-- | jstests/noPassthroughWithMongod/restart_catalog_interrupts_background_validation.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/jstests/noPassthroughWithMongod/restart_catalog_interrupts_background_validation.js b/jstests/noPassthroughWithMongod/restart_catalog_interrupts_background_validation.js new file mode 100644 index 00000000000..7c6c67f77ca --- /dev/null +++ b/jstests/noPassthroughWithMongod/restart_catalog_interrupts_background_validation.js @@ -0,0 +1,73 @@ +/** + * Verifies that background validation is interrupted when the `restartCatalog` command is + * executed. + * + * Only run this against WiredTiger, which supports checkpoint cursors. + * @tags: [requires_wiredtiger, requires_persistence] + */ +(function() { +"use strict"; +load("jstests/libs/check_log.js"); + +const dbName = "restart_catalog_interrupts_background_validation"; +const collName = "test"; + +let testDb = db.getSiblingDB(dbName); +let testColl = testDb.getCollection(collName); +testColl.drop(); + +const setFailpoint = () => { + assert.commandWorked(testDb.adminCommand( + {configureFailPoint: "hangDuringYieldingLocksForValidation", mode: "alwaysOn"})); +}; + +const unsetFailpoint = () => { + assert.commandWorked(testDb.adminCommand( + {configureFailPoint: "hangDuringYieldingLocksForValidation", mode: "off"})); +}; + +const waitUntilFailpoint = () => { + checkLog.contains(testDb.getMongo(), + "Hanging on fail point 'hangDuringYieldingLocksForValidation'"); +}; + +const setupCollection = () => { + // Clear the log to get rid of any existing fail point logging that will be used to hang on. + assert.commandWorked(testDb.adminCommand({clearLog: 'global'})); + + assert.commandWorked(testColl.createIndex({x: 1})); + + // Insert 10,000 documents because validation will yield every 4096 entries fetched. + const docsToInsert = 10000; + var bulk = testColl.initializeUnorderedBulkOp(); + for (var i = 0; i < docsToInsert; i++) { + bulk.insert({x: i}); + } + assert.commandWorked(bulk.execute()); + + // Create a checkpoint of the data. + assert.commandWorked(testDb.fsyncLock()); + assert.commandWorked(testDb.fsyncUnlock()); +}; + +// Create an index, insert some test data and force a checkpoint. +setupCollection(); + +let awaitBackgroundValidationFailed; +try { + setFailpoint(); + awaitBackgroundValidationFailed = startParallelShell(function() { + assert.commandFailedWithCode( + db.getSiblingDB("restart_catalog_interrupts_background_validation") + .runCommand({validate: "test", background: true}), + ErrorCodes.Interrupted); + }); + + waitUntilFailpoint(); + assert.commandWorked(db.adminCommand({restartCatalog: 1})); +} finally { + unsetFailpoint(); +} + +awaitBackgroundValidationFailed(); +}()); |