-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
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.