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

Storage engine clean shutdown can race with startup

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Execution Team 2021-09-06
    • 10

      In certain circumstances, storage engine startup can race with clean shutdown, and lead to the following invariant failure:

      Invariant failure !listenerNotRegistered
      

      The shutdown task that is called from the signal handler to cleanly shut down the storage engine holds a Global X lock. But the initAndListen thread, which initializes the storage engine, and which registers the TimestampMonitor listener, does not hold this lock.

      The shutdown path assumes that the storage engine has been completely initialized, but that is not the case. So the server can crash if it is shut down cleanly before the storage engine finishes starting up.

      I'm surprised we don't already hold the Global X lock during storage engine initialization, but perhaps we should. An alternative to taking a global lock would be to keep shutdown expeditious and permit this type of race by relaxing the existing invariant.

            Assignee:
            benety.goh@mongodb.com Benety Goh
            Reporter:
            louis.williams@mongodb.com Louis Williams
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: