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

Concurrent aggregations with $out on a shard server can deadlock with each other

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.6
    • Affects Version/s: 4.1.3
    • Component/s: Querying
    • None
    • Fully Compatible
    • ALL
    • Query 2018-11-05, Query 2018-11-19
    • 45

      A single aggregation request with $out takes:

      • the global lock in IS for a collection lock on the input collection from the client's OperationContext
      • the global lock in IS for a collection lock on config.collections and config.chunks from the ShardServerCatalogCacheLoader from one of the loader's OperationContexts
      • the global lock in X for renameIfOptionsAndIndexesHaveNotChanged() from the client's OperationContext

      Enqueuing a global X lock request blocks all later global lock requests.

      So, if one agg request's global X lock request is enqueued in between a second agg request's two global IS lock requests, the three threads can deadlock.

      I think it also may be possible for any operation that takes a global X lock to deadlock with a single agg with $out? I am not totally sure though, which is why I titled the ticket as I did for now.

      I am not sure whether this affects versions before master, so have just marked it as affecting 4.1.3 for now.

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            esha.maharishi@mongodb.com Esha Maharishi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: