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

remove try/catch in background job

    XMLWordPrintableJSON

Details

    • Fully Compatible
    • ALL
    • Dev Tools 2018-12-03, Dev Tools 2018-12-17, Dev Tools 2018-12-31
    • 0

    Description

      BackgroundJob::jobBody() has this code:

          try {
              run();
          } catch (const std::exception& e) {
              error() << "backgroundjob " << threadName << " exception: " << redact(e.what());
              throw;
          }
      

      The problem with this is that the rethrow will always trigger std::terminate(), since there are no further exception handlers up the stack. The catch-and-rethrow here will make the resulting stack trace appear from the point of rethrow instead of at the point of the original throw, making the stack trace useless for debugging. If we removed this try/catch, the stack trace would become useful again. Note that our terminate handler already successfully logs e.what(), so no functionality will be lost.

      Attachments

        Activity

          People

            gabriel.russell@mongodb.com Gabriel Russell (Inactive)
            milkie@mongodb.com Eric Milkie
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: