diff options
author | Ali Mir <ali.mir@mongodb.com> | 2021-01-25 15:33:33 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-01-27 15:54:02 +0000 |
commit | 145b26cdb01e5f831c522b0b567673e803657d7b (patch) | |
tree | 9447f3d9317bf4045645ab2ea069286384de66d0 /jstests/hooks | |
parent | 49985eb4a42f43e5da75f6c8da9a0cb76c482c9e (diff) | |
download | mongo-145b26cdb01e5f831c522b0b567673e803657d7b.tar.gz |
SERVER-53994 Remove redundant try-catch statement in run_reconfig_background.js
Diffstat (limited to 'jstests/hooks')
-rw-r--r-- | jstests/hooks/run_reconfig_background.js | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/jstests/hooks/run_reconfig_background.js b/jstests/hooks/run_reconfig_background.js index bf88bc2bd49..ae3ee237b9a 100644 --- a/jstests/hooks/run_reconfig_background.js +++ b/jstests/hooks/run_reconfig_background.js @@ -24,6 +24,9 @@ function isIgnorableError(codeName) { return false; } +/** + * Returns true if the error code indicates the node is currently shutting down. + */ function isShutdownError(code) { return code === ErrorCodes.ShutdownInProgress || code === ErrorCodes.InterruptedAtShutdown; } @@ -71,18 +74,7 @@ function reconfigBackground(primary, numNodes) { // could lead to generating an overwhelming amount of log messages. let conn; quietly(() => { - // It's possible that the primary we passed in gets killed by the kill primary hook. - // During shutdown, mongod will respond to incoming hello requests with ShutdownInProgress - // or InterruptedAtShutdown. This hook should ignore both cases and wait until we have a - // new primary in a subsequent run. - try { - conn = new Mongo(primary); - } catch (e) { - if (!isShutdownError(e.code)) { - throw e; - } - return {ok: 1}; - } + conn = new Mongo(primary); }); assert.neq( null, conn, "Failed to connect to primary '" + primary + "' for background reconfigs"); @@ -157,10 +149,11 @@ try { return regex.test(e.message); })) { jsTestLog("Ignoring replica set monitor error" + tojson(e)); - } else if (e.code === ErrorCodes.ShutdownInProgress) { - // When a node is being shutdown, it is possible to fail isMaster requests with - // ShutdownInProgress. If we encounter this error, ignore it and find a new - // primary. + } else if (isShutdownError(e.code)) { + // It's possible that the primary we passed in gets killed by the kill primary hook. + // During shutdown, mongod will respond to incoming hello requests with ShutdownInProgress + // or InterruptedAtShutdown. This hook should ignore both cases and wait until we have a + // new primary in a subsequent run. jsTestLog("Ignoring ShutdownInProgress error" + tojson(e)); } else { jsTestLog(`run_reconfig_background unexpected error: ${tojson(e)}`); |