[SERVER-53994] Remove redundant try-catch statement in run_reconfig_background.js Created: 22/Jan/21  Updated: 29/Oct/23  Resolved: 27/Jan/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 4.9.0

Type: Improvement Priority: Major - P3
Reporter: Ali Mir Assignee: Ali Mir
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Repl 2021-01-25, Repl 2021-02-08
Participants:

 Description   

While working on BF-19854, I noticed that we try to catch ShutdownInProgress errors in two places in run_reconfig_background.js. The first is here, and the second is here. If we successfully catch the ShutdownInProgress error in the first catch statement, then the second catch statement will never be executed. We should consolidate the error catching in one place in this hook.

There is also another JavaScript error in the first try-catch:

try {            
   conn = new Mongo(primary);        
} catch (e) {            
   if (!isShutdownError(e.code)) {                
      throw e;            
   }            
      return {ok: 1};        
   }

Here, we intend the for return statement to finish executing the whole reconfigBackground function. However, this statement only returns the anonymous function argument passed into the quietly function. As a result, if we successfully catch a ShutdownInProgress error, we will continue executing reconfigBackground and eventually fail below, as the node is shutting down. This bug will also be addressed in this patch.



 Comments   
Comment by Githook User [ 27/Jan/21 ]

Author:

{'name': 'Ali Mir', 'email': 'ali.mir@mongodb.com', 'username': 'ali-mir'}

Message: SERVER-53994 Remove redundant try-catch statement in run_reconfig_background.js
Branch: master
https://github.com/mongodb/mongo/commit/145b26cdb01e5f831c522b0b567673e803657d7b

Generated at Thu Feb 08 05:32:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.