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

remove try/catch in background job

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      Dev Tools 2018-12-03, Dev Tools 2018-12-17, Dev Tools 2018-12-31
    • Linked BF Score:
      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

            Assignee:
            gabriel.russell Gabriel Russell
            Reporter:
            milkie Eric Milkie
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: