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

tolerance for thread creation failure is inconsistent

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Service Arch
    • 11

      Failure to spawn is not fatal for ingress threads currently. They're different from stdx::threads for which it is fatal. Unfortunately the kernel doesn't know they're different and they share a NPROC quota with all threads in all processes owned by the user running the server.

      The idea that stdx::thread is used for every non-ingress thread but doesn't allow for thread creation failure is limiting. The class docs say this is deliberate, but I think they are assuming a particular usage, and the class is used for diverse purposes.

      I think the extra setup done by stdx::thread is useful even without its intolerance of exceptions. We should have an offering that's got the extra stdx::thread initialization, but allows for spawn failure by simply allowing the std::system_error to propagate out of the constructor.

      We should remove noexcept here anyway, as it's broken in GCC. The exception thrown by the thread constructor may be unavailable to the terminate handler. Noexcept, in an attempt to make error handling better, is potentially making the error handling worse. We can probably just remove it.


      It also says it's identical to std::thread in all other ways and this is no longer accurate. It does a fair amount of mongo-specific setup in its constructor (e.g. ThreasSafetyContext, sigaltstack, set_terminate handler for Win32, ...). It's also doing an extra move of its callable argument and its bound arguments if any, into a tuple.

            Assignee:
            backlog-server-servicearch [DO NOT USE] Backlog - Service Architecture
            Reporter:
            billy.donahue@mongodb.com Billy Donahue
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: