|
Ephemeral for test record stores use a mutex to protect concurrent access to their data. Technically, because ephemeral for test is not a document locking record store, this shouldn't be needed for data collections, just the _mdb_catalog. Unfortunately knowing whether a record store is for the _mdb_catalog is a layering violation.
The problem that can arise is that an insert into a capped collection can trigger a delete. A delete on a record goes through a callback, which is ultimately managed by the CursorManager and forwarded to all the individual plans being run. This BF found that the in-memory, non-indexed sorting stage queries the record store for the deleted record (presumably to ensure the query does not return the capped-deleted document in the result set?)
Re-entering the same ephemeral for test record store causes its internal mutex to be double locked. For informational purposes (i.e: not a mandated solution), another example of a callback in this class unlocks the mutex before calling the arbitrary code, and relocks when returning: https://github.com/mongodb/mongo/blob/9e8cce334f74d4e70661bcb3921e069c9a0b248b/src/mongo/db/storage/ephemeral_for_test/ephemeral_for_test_record_store.cpp#L488-L493
|