Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-53994

Remove redundant try-catch statement in run_reconfig_background.js

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.9.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • Repl 2021-01-25, Repl 2021-02-08

      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.

            Assignee:
            ali.mir@mongodb.com Ali Mir
            Reporter:
            ali.mir@mongodb.com Ali Mir
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: