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

Remove redundant try-catch statement in run_reconfig_background.js

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.9.0
    • Component/s: None
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Sprint:
      Repl 2021-01-25, Repl 2021-02-08

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: