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

mapReduce's postProcessCollection() should take db write lock instead of global write lock

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.4.0
    • Affects Version/s: 3.5.11
    • Component/s: Querying
    • Query
    • Fully Compatible

      mapReduce's postProcessCollection() on mongod may take a global write lock. The comment above it says it's because renaming the temp collection to the final output collection may be a rename across databases.

      However, I believe it's enough to just hold a database lock (not global lock) here. The temp collection is always created in the same database as the final output collection, so the rename should never actually be across databases.

      The online docs suggest that if the 'nonAtomic' option to mapReduce is true, only a database (of the final output collection) will be locked.

      Further, it looks like the comment about renaming across databases was introduced in this commit, and prior to that, Eliot had commented that a global lock probably did not need to be taken.

      This is important because renaming a collection across databases does not preserve the collection's UUID. For the UUIDs project, I am assuming that the global lock taken here is errant, and that the rename can never be across databases.

      CC marko.vojvodic

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            esha.maharishi@mongodb.com Esha Maharishi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: