summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuganthi Mani <suganthi.mani@mongodb.com>2019-09-24 00:27:20 +0000
committerevergreen <evergreen@mongodb.com>2019-09-24 00:27:20 +0000
commitabc05fba0123c1dbc478f770e4aca6c763eaf073 (patch)
tree2a8601d70d667d97a81dfccc94d3b2256c84ad44
parentce1b27cb76dd0709273ac80423b9a35d72edc6fd (diff)
downloadmongo-abc05fba0123c1dbc478f770e4aca6c763eaf073.tar.gz
SERVER-43237 replSetFreeze and replSetStepDown cmd done part of
restartNode()/transitionToSteadyStateOperations() in rollback test should be resilient of network errors. (cherry picked from commit 397f0556a9e2d4fa3106d9490611b405d0e1ecf3)
-rw-r--r--jstests/replsets/libs/rollback_test.js19
1 files changed, 12 insertions, 7 deletions
diff --git a/jstests/replsets/libs/rollback_test.js b/jstests/replsets/libs/rollback_test.js
index 1576b12c5d1..8c5002f63c7 100644
--- a/jstests/replsets/libs/rollback_test.js
+++ b/jstests/replsets/libs/rollback_test.js
@@ -229,9 +229,6 @@ function RollbackTest(name = "RollbackTest", replSet) {
`may prevent a rollback here.`);
}
- // Unfreeze the node if it was previously frozen, so that it can run for the election.
- assert.commandWorked(curSecondary.adminCommand({replSetFreeze: 0}));
-
// Ensure that the tiebreaker node is connected to the other nodes. We must do this after
// we are sure that rollback has completed on the rollback node.
tiebreakerNode.reconnect([curPrimary, curSecondary]);
@@ -244,6 +241,9 @@ function RollbackTest(name = "RollbackTest", replSet) {
log(`Rollback on ${curSecondary.host} (if needed) and awaitReplication completed`, true);
+ // Unfreeze the node if it was previously frozen, so that it can run for the election.
+ assert.commandWorked(curSecondary.adminCommand({replSetFreeze: 0}));
+
// We call transition to steady state ops after awaiting replication has finished,
// otherwise it could be confusing to see operations being replicated when we're already
// in rollback complete state.
@@ -437,10 +437,11 @@ function RollbackTest(name = "RollbackTest", replSet) {
if (curState === State.kSyncSourceOpsDuringRollback &&
rst.getNodeId(curSecondary) === nodeId) {
assert.soon(() => {
- // Try stepping down the rollback node if it became the primary after its
- // restart, as it might have caught up with the original primary.
- curSecondary.adminCommand({"replSetStepDown": kForeverSecs, "force": true});
try {
+ // Try stepping down the rollback node if it became the primary after its
+ // restart, as it might have caught up with the original primary and facing
+ // arbitrary machine/network slowness.
+ curSecondary.adminCommand({"replSetStepDown": kForeverSecs, "force": true});
// Prevent rollback node from running election. There is a chance that this
// node might have started running election or became primary after
// 'replSetStepDown' cmd, so 'replSetFreeze' cmd can fail.
@@ -448,10 +449,14 @@ function RollbackTest(name = "RollbackTest", replSet) {
curSecondary.adminCommand({"replSetFreeze": kForeverSecs}));
return true;
} catch (e) {
- if (e.code === ErrorCodes.NotSecondary ||
+ // Network error can happen if the node simultaneously tries to transition to
+ // ROLLBACK state.
+ if (isNetworkError(e) || e.code === ErrorCodes.NotSecondary ||
e.code === ErrorCodes.NotYetInitialized) {
+ log('Failed to freeze the node.' + tojson(e));
return false;
}
+
throw e;
}
}, `Failed to run replSetFreeze cmd on ${curSecondary.host}`);