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

Reverse mutex acquisition order in CatalogCache::_scheduleDatabaseRefresh

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.11, 4.2.0-rc3, 4.3.1
    • Affects Version/s: 4.0.10, 4.2.0-rc1
    • Component/s: Sharding
    • None
    • Fully Compatible
    • ALL
    • v4.2, v4.0
    • Sharding 2019-07-15

      CatalogCache::_mutex -> ShardServerCatalogCacheLoader::_mutex order:

      CatalogCache::_scheduleDatabaseRefresh has catalog cache mutex and calls getDatabase:
      https://github.com/mongodb/mongo/blob/2393ed14199eddebe25e56bc0a8fe1d47f2297cf/src/mongo/s/catalog_cache.cpp#L532

      which will take the ShardServerCCL _mutex at the beginning of the call.

      ShardServerCCL::_mutex -> CatalogCache::_mutex order:

      Inside the async task lamda we take the ShardServerCCL mutex then tries to run a callback:
      https://github.com/mongodb/mongo/blob/2393ed14199eddebe25e56bc0a8fe1d47f2297cf/src/mongo/db/s/shard_server_catalog_cache_loader.cpp#L460

      And the callback tries to get the CatalogCache::_mutex:

      https://github.com/mongodb/mongo/blob/2393ed14199eddebe25e56bc0a8fe1d47f2297cf/src/mongo/s/catalog_cache.cpp#L523

            Assignee:
            kaloian.manassiev@mongodb.com Kaloian Manassiev
            Reporter:
            randolph@mongodb.com Randolph Tan
            Votes:
            0 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: