diff options
Diffstat (limited to 'jstests/replsets/rollback_via_refetch_survives_nonexistent_collection_drop.js')
-rw-r--r-- | jstests/replsets/rollback_via_refetch_survives_nonexistent_collection_drop.js | 92 |
1 files changed, 45 insertions, 47 deletions
diff --git a/jstests/replsets/rollback_via_refetch_survives_nonexistent_collection_drop.js b/jstests/replsets/rollback_via_refetch_survives_nonexistent_collection_drop.js index f4c4b7575ad..7cf47857d2a 100644 --- a/jstests/replsets/rollback_via_refetch_survives_nonexistent_collection_drop.js +++ b/jstests/replsets/rollback_via_refetch_survives_nonexistent_collection_drop.js @@ -10,65 +10,63 @@ */ (function() { - "use strict"; - load("jstests/libs/check_log.js"); - load("jstests/replsets/libs/rollback_test.js"); +"use strict"; +load("jstests/libs/check_log.js"); +load("jstests/replsets/libs/rollback_test.js"); - const dbName = "test"; - const collName = "rollback_via_refetch_survives_nonexistent_collection_drop"; +const dbName = "test"; +const collName = "rollback_via_refetch_survives_nonexistent_collection_drop"; - // Provide RollbackTest with custom ReplSetTest so we can set enableMajorityReadConcern. - const rst = new ReplSetTest({ - name: collName, - nodes: 3, - useBridge: true, - nodeOptions: {enableMajorityReadConcern: "false"} - }); +// Provide RollbackTest with custom ReplSetTest so we can set enableMajorityReadConcern. +const rst = new ReplSetTest( + {name: collName, nodes: 3, useBridge: true, nodeOptions: {enableMajorityReadConcern: "false"}}); - rst.startSet(); - const config = rst.getReplSetConfig(); - config.members[2].priority = 0; - config.settings = {chainingAllowed: false}; - rst.initiate(config); +rst.startSet(); +const config = rst.getReplSetConfig(); +config.members[2].priority = 0; +config.settings = { + chainingAllowed: false +}; +rst.initiate(config); - const rollbackTest = new RollbackTest(collName, rst); +const rollbackTest = new RollbackTest(collName, rst); - // Stop replication from the current primary, the rollback node. - const rollbackNode = rollbackTest.transitionToRollbackOperations(); - const rollbackDB = rollbackNode.getDB(dbName); +// Stop replication from the current primary, the rollback node. +const rollbackNode = rollbackTest.transitionToRollbackOperations(); +const rollbackDB = rollbackNode.getDB(dbName); - jsTestLog("Turning on the rollbackExitEarlyAfterCollectionDrop fail point"); - assert.commandWorked(rollbackDB.adminCommand( - {configureFailPoint: 'rollbackExitEarlyAfterCollectionDrop', mode: 'alwaysOn'})); +jsTestLog("Turning on the rollbackExitEarlyAfterCollectionDrop fail point"); +assert.commandWorked(rollbackDB.adminCommand( + {configureFailPoint: 'rollbackExitEarlyAfterCollectionDrop', mode: 'alwaysOn'})); - // Create a collection on the rollback node. - assert.commandWorked(rollbackDB.runCommand({create: collName})); +// Create a collection on the rollback node. +assert.commandWorked(rollbackDB.runCommand({create: collName})); - // Step down the current primary and elect the node that does not have the collection. - rollbackTest.transitionToSyncSourceOperationsBeforeRollback(); +// Step down the current primary and elect the node that does not have the collection. +rollbackTest.transitionToSyncSourceOperationsBeforeRollback(); - jsTestLog("Attempting to roll back."); - // Make the old primary rollback against the new primary. This attempt should fail because the - // rollbackExitEarlyAfterCollectionDrop fail point is set. We fail with a recoverable error - // so that the rollback will be retried. - rollbackTest.transitionToSyncSourceOperationsDuringRollback(); +jsTestLog("Attempting to roll back."); +// Make the old primary rollback against the new primary. This attempt should fail because the +// rollbackExitEarlyAfterCollectionDrop fail point is set. We fail with a recoverable error +// so that the rollback will be retried. +rollbackTest.transitionToSyncSourceOperationsDuringRollback(); - // Make sure we exit the rollback early by checking for the correct log messages. - checkLog.contains(rollbackDB.getMongo(), - "rollbackExitEarlyAfterCollectionDrop fail point enabled."); +// Make sure we exit the rollback early by checking for the correct log messages. +checkLog.contains(rollbackDB.getMongo(), + "rollbackExitEarlyAfterCollectionDrop fail point enabled."); - jsTestLog("Turning off the rollbackExitEarlyAfterCollectionDrop fail point"); - // A rollback attempt after turning off the fail point should succeed even if we already - // dropped the collection. - assert.commandWorked(rollbackDB.adminCommand( - {configureFailPoint: 'rollbackExitEarlyAfterCollectionDrop', mode: 'off'})); +jsTestLog("Turning off the rollbackExitEarlyAfterCollectionDrop fail point"); +// A rollback attempt after turning off the fail point should succeed even if we already +// dropped the collection. +assert.commandWorked(rollbackDB.adminCommand( + {configureFailPoint: 'rollbackExitEarlyAfterCollectionDrop', mode: 'off'})); - rollbackTest.transitionToSteadyStateOperations(); +rollbackTest.transitionToSteadyStateOperations(); - // After a successful rollback attempt, we should have seen the following log message to ensure - // that we tried to drop a non-existent collection and continued without acquiring a database - // lock. - checkLog.contains(rollbackDB.getMongo(), "This collection does not exist"); +// After a successful rollback attempt, we should have seen the following log message to ensure +// that we tried to drop a non-existent collection and continued without acquiring a database +// lock. +checkLog.contains(rollbackDB.getMongo(), "This collection does not exist"); - rollbackTest.stop(); +rollbackTest.stop(); }());
\ No newline at end of file |