[SERVER-69770] Enforce the required lock mode in the CollectionShardingRuntime API Created: 16/Sep/22  Updated: 29/Oct/23  Resolved: 03/Jan/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 6.3.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Jordi Serra Torrens Assignee: Daniel Gomez Ferro
Resolution: Fixed Votes: 0
Labels: PM-2144-Cleanup
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Sharding EMEA
Backwards Compatibility: Fully Compatible
Sprint: Execution Team 2022-12-26, Execution Team 2023-01-09
Participants:

 Description   

SERVER-69435 introduces a method that acquires the CollectionShardingRuntime with a given lock mode (shared or exclusive). It sometimes may not be clear which lock mode should be used to do a particular action on the CSR. This could lead to the introduction of bugs in the future.

We should make the type of lock required be enforced by the API. One idea is to have two acquisition methods:

  • One that takes the exclusive lock and returns a non-const CSR.
  • The other takes the shared lock and returns a const CSR.
    All methods that modify the CSR (i.e. need exclusive lock) should be made non-const. All methods that do not modify the CSR should be made const.


 Comments   
Comment by Githook User [ 18/Jan/23 ]

Author:

{'name': 'Daniel Gómez Ferro', 'email': 'daniel.gomezferro@mongodb.com', 'username': 'dgomezferro'}

Message: SERVER-69770 Follow up, const improvements for CSR shared acquisition
Branch: master
https://github.com/mongodb/mongo/commit/73bb44178a3b88aa7432a58f47ad20eab28ad115

Comment by Githook User [ 03/Jan/23 ]

Author:

{'name': 'Daniel Gómez Ferro', 'email': 'daniel.gomezferro@mongodb.com', 'username': 'dgomezferro'}

Message: SERVER-69770 Enforce lock mode in CollectionShardingRuntime API
Branch: master
https://github.com/mongodb/mongo/commit/6ec1e03c0968d786f62cad9db47408411301e7af

Comment by Antonio Fuschetto [ 16/Sep/22 ]

This makes sense for the DatabaseShardingState as well.

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