[SERVER-70154] DatabaseShardingState inappropriately constructs a RESOURCE_MUTEX ResourceId, leading to uncaught exception Created: 01/Oct/22  Updated: 19/Oct/22  Resolved: 19/Oct/22

Status: Closed
Project: Core Server
Component/s: Concurrency, Sharding
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Max Hirschhorn Assignee: Jordi Serra Torrens
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-70198 Use one single RESOURCE_MUTEX to prot... Closed
depends on SERVER-70610 Move the DatabaseShardingState RESOUR... Closed
is depended on by SERVER-70467 Prevent manually using RESOURCE_MUTEX Closed
Problem/Incident
is caused by SERVER-69434 Make the DSS acquisition a RAII Closed
Related
related to SERVER-70431 Checkpointing manually constructs Res... Closed
is related to SERVER-70322 BalancerStatsRegistry inappropriately... Closed
is related to SERVER-70536 Invalid construction of "checkpoint" ... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:
Linked BF Score: 137

 Description   

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.



 Comments   
Comment by Jordi Serra Torrens [ 19/Oct/22 ]

Fixed by SERVER-70198

Comment by Jordi Serra Torrens [ 04/Oct/22 ]

This will be fixed by SERVER-70198, after which DatabaseShardingState will no longer construct ResourceIds outside of ResourceIdFactory.

Generated at Thu Feb 08 06:15:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.