The RAII classes in d_concurrency.h/.cpp are strictly part of the lock manager. As such, they should be completely decoupled from the database/collection catalog and should not know about UUIDs or anything else that is strictly catalog.
This is not the case currently since the CollectionLock object at the very least is aware of the collection catalog which is a layering violation that can lead to bugs such as SERVER-67382.
UPDATE:
Proposed solution is to add a lightweight RAII type on top of the CollectionLock use. The selection to use the CollectionLock in the first place, over AutoGetCollection*, may imply that sharding/view/storage checks are not desired for the use cases. So we'd have to investigate what works.
- related to
-
SERVER-67382 Race condition in the UUID <-> NSS resolution in the multi-collection locking path
- Closed