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

Illegal concurrent access to KVDatabaseCatalogEntryBase::_collections

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.2.0
    • Affects Version/s: None
    • Component/s: Catalog
    • None
    • Fully Compatible
    • ALL
    • Execution Team 2020-04-06, Execution Team 2020-04-20

      There is an apparent thread-safety error which can occur if a listDatabases command is running concurrently with a renameCollection command. This is closely related to the problem observed in SERVER-34531. As described in SERVER-34531, the listDatabases command takes a GlobalLock in MODE_IS. The renameCollection command acquires a GlobalLock in MODE_IX and a MODE_X database lock on the database on which it is performing the rename. Global locks of type IX and IS do not conflict, so the listDatabases command and renameCollection command are allowed to run concurrently.

      The listDatabases command reads from KVDatabaseCatalogEntryBase::_collections, a std::map which is not thread-safe, in order to check whether the database is empty. At the same time, the renameCollection may be writing to the _collections map in order to represent the rename in the catalog data structures.

      As far as I can tell, the fix for SERVER-34531 ensured that listDatabases would not fail to report a database due to a concurrent rename, but it did not prevent concurrent access to the _collections map.

            Assignee:
            geert.bosch@mongodb.com Geert Bosch
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: