diff options
author | Vesselina Ratcheva <vesselina.ratcheva@10gen.com> | 2020-02-13 19:39:27 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-26 10:21:37 +0000 |
commit | 1939a3ca2a29d22e7b9976171bf2cc54bd9a1846 (patch) | |
tree | 64732f4be61fa7f988202e1d478dbd40590d9ac0 /jstests | |
parent | 24b02a2342f59e9f6f3d5ad775252d48a2731d7b (diff) | |
download | mongo-1939a3ca2a29d22e7b9976171bf2cc54bd9a1846.tar.gz |
SERVER-45178 Always update rollbackId before truncating oplog for rollback-via-refetch
create mode 100644 jstests/replsets/rollback_via_refetch_update_rollback_id_before_oplog_truncation.js
(cherry picked from commit 04a2c9acc7ca061fb86736b377b897b11f6c7c48)
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/replsets/rollback_via_refetch_update_rollback_id_before_oplog_truncation.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/jstests/replsets/rollback_via_refetch_update_rollback_id_before_oplog_truncation.js b/jstests/replsets/rollback_via_refetch_update_rollback_id_before_oplog_truncation.js new file mode 100644 index 00000000000..d560cc7d419 --- /dev/null +++ b/jstests/replsets/rollback_via_refetch_update_rollback_id_before_oplog_truncation.js @@ -0,0 +1,58 @@ +/** + * This test demonstrates that rollback via refetch always increments the rollback id as soon as it + * resolves the common point and before proceeding with other operations. + * + * This is a regression test that makes sure we avoid the scenario where we truncate our oplog (at + * which point the rollback is effectively finished), then shut down uncleanly before we get a + * chance to update the rollbackId. + * + * @tags: [requires_journaling] + */ + +(function() { + "use strict"; + load("jstests/replsets/libs/rollback_test.js"); + load("jstests/replsets/rslib.js"); + + const name = jsTestName(); + TestData.allowUncleanShutdowns = true; + + jsTest.log("Set up a RollbackTest with enableMajorityReadConcern=false"); + const rst = new ReplSetTest({ + name, + nodes: [{}, {}, {rsConfig: {arbiterOnly: true}}], + useBridge: true, + nodeOptions: {enableMajorityReadConcern: "false"}, + settings: {chainingAllowed: false} + }); + + rst.startSet(); + rst.initiate(); + + const rollbackTest = new RollbackTest(name, rst); + const rollbackNode = rollbackTest.transitionToRollbackOperations(); + + const baseRBID = assert.commandWorked(rollbackNode.adminCommand("replSetGetRBID")).rbid; + + rollbackTest.transitionToSyncSourceOperationsBeforeRollback(); + + jsTestLog("Make rollback-via-refetch exit early after truncating the oplog"); + assert.commandWorked(rollbackNode.adminCommand( + {configureFailPoint: "rollbackExitEarlyAfterCollectionDrop", mode: "alwaysOn"})); + + rollbackTest.transitionToSyncSourceOperationsDuringRollback(); + + jsTestLog("Wait until we hit the failpoint"); + checkLog.contains(rollbackNode, "rollbackExitEarlyAfterCollectionDrop fail point enabled"); + + // Check that the RBID has still managed to advance. + // Looking at the RBID directly is our first line of defense. + assert.eq(baseRBID + 1, assert.commandWorked(rollbackNode.adminCommand("replSetGetRBID")).rbid); + + assert.commandWorked(rollbackNode.adminCommand( + {configureFailPoint: "rollbackExitEarlyAfterCollectionDrop", mode: "off"})); + + // Verify that the node can rejoin the set as normal. + rollbackTest.transitionToSteadyStateOperations(); + rollbackTest.stop(); +}());
\ No newline at end of file |