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

killSessions command attempts to kill a transaction while holding SessionCatalog::_mutex, which leads to deadlock

    XMLWordPrintable

    Details

    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.0
    • Sprint:
      Repl 2018-06-18

      Description

      Attempting to acquire a LockManager lock while holding a mutex is prone to deadlock. The SessionCatalog::scanSessions() function locks the session catalog and executes an arbitrary function on any matching sessions. For the "killSessions" command, this means that while holding the SessionCatalog::_mutex, it calls CursorManager::killAllCursorsForTransaction(), which for a find cursor attempts to acquire the collection lock in CursorManager::withCursorManager(). Since the killAllExpiredTransactions() function also calls SessionCatalog::scanSessions(), it isn't possible to reap expired transactions while the "killSessions" command is running. It similarly isn't possible to commit or abort a transaction while the "killSessions" command is running because SessionCatalog::checkOutSession() must acquire the SessionCatalog::_mutex.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tess.avitabile Tess Avitabile
              Reporter:
              max.hirschhorn Max Hirschhorn
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: