The changes from a383a13 as part of
SERVER-69434 changed DatabaseShardingState to construct a ResourceId(RESOURCE_MUTEX, dbName). Constructing a RESOURCE_MUTEX ResourceId outside of ResourceIdFactory is a violation of ResoureceIdFactory::nameForId(). The RESOURCE_MUTEX ResourceType is a lock type designed to use the position within the ResoureceIdFactory::labels vector as the hash of the ResourceId. ResourceId(RESOURCE_MUTEX, dbName) will take the hash of the database name and therefore be very unlikely to correspond to an element within the ResoureceIdFactory::labels vector.
ResourceId::toString() is called when the lock cannot be acquired within the allotted time and leads to an uncaught std::out_of_range exception.