summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2021-11-17 03:26:19 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-11-17 03:51:33 +0000
commit4c57f6bca3334bee1118a695d871db5346c75ff5 (patch)
tree26df191dc151daa46ae43e58aec9d63eedabfdb4
parent6c3707f9e2b460efc3641d83d9c6138204e1c1ba (diff)
downloadmongo-4c57f6bca3334bee1118a695d871db5346c75ff5.tar.gz
SERVER-61483 Retry once in ReshardingTest when disabling failpoints.
(cherry picked from commit d9fcd9f124ece9ab0b3a3c46cb6d7052b7282dd2)
-rw-r--r--jstests/sharding/libs/resharding_test_fixture.js34
1 files changed, 31 insertions, 3 deletions
diff --git a/jstests/sharding/libs/resharding_test_fixture.js b/jstests/sharding/libs/resharding_test_fixture.js
index dec8f0b9c3b..1f72531643b 100644
--- a/jstests/sharding/libs/resharding_test_fixture.js
+++ b/jstests/sharding/libs/resharding_test_fixture.js
@@ -540,11 +540,16 @@ var ReshardingTest = class {
});
} else {
this._callFunctionSafely(() => {
- this._pauseCoordinatorBeforeBlockingWrites.off();
+ this.retryOnceOnNetworkError( //
+ () => this._pauseCoordinatorBeforeBlockingWrites.off());
+
postCheckConsistencyFn();
- this._pauseCoordinatorBeforeDecisionPersistedFailpoint.off();
+ this.retryOnceOnNetworkError(
+ () => this._pauseCoordinatorBeforeDecisionPersistedFailpoint.off());
+
postDecisionPersistedFn();
- this._pauseCoordinatorBeforeCompletionFailpoint.off();
+ this.retryOnceOnNetworkError(
+ () => this._pauseCoordinatorBeforeCompletionFailpoint.off());
});
}
@@ -902,4 +907,27 @@ var ReshardingTest = class {
return cloneTimestamp;
}
+
+ /**
+ * Calls and returns the value from the supplied function.
+ *
+ * If a network error is thrown during its execution, then this function will invoke the
+ * supplied function a second time. This pattern is useful for tolerating network errors which
+ * result from elections triggered by any of the stepUpNewPrimaryOnShard(),
+ * killAndRestartPrimaryOnShard(), and shutdownAndRestartPrimaryOnShard() methods.
+ *
+ * @param fn - the function to be called.
+ * @returns the return value from fn.
+ */
+ retryOnceOnNetworkError(fn) {
+ try {
+ return fn();
+ } catch (e) {
+ if (!isNetworkError(e)) {
+ throw e;
+ }
+
+ return fn();
+ }
+ }
};