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

    • Fully Compatible
    • ALL
    • v4.0
    • Repl 2018-06-18

      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.

            Assignee:
            tess.avitabile@mongodb.com Tess Avitabile (Inactive)
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: