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

Illegal concurrent access to KVDatabaseCatalogEntryBase::_collections

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 4.2.0
    • Catalog
    • None
    • Fully Compatible
    • ALL
    • Execution Team 2020-04-06, Execution Team 2020-04-20

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: