[SERVER-62432] Ensure safe access to ShardingDDLCoordinator instance state documents Created: 07/Jan/22  Updated: 29/Oct/23  Resolved: 12/May/22

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 5.0.0, 5.2.0, 5.1.0
Fix Version/s: 5.0.10, 6.0.0-rc9, 6.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Jordi Serra Torrens Assignee: Enrico Golfieri
Resolution: Fixed Votes: 0
Labels: sharding-wfbf-day
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Duplicate
is duplicated by SERVER-66439 Concurrent `checkIfOptionsConflict` r... Closed
is duplicated by SERVER-65500 Unprotected concurrent access to coor... Closed
Related
related to SERVER-66439 Concurrent `checkIfOptionsConflict` r... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v6.0, v5.0
Sprint: Sharding EMEA 2022-02-07, Sharding EMEA 2022-02-21, Sharding EMEA 2022-04-18, Sharding EMEA 2022-05-02, Sharding EMEA 2022-05-16
Participants:
Linked BF Score: 15

 Description   

Instances of ShardingDDLCoordinators maintain an in-memory copy of their state document (e.g). The coordinator's main thread reads and writes it (e.g.). Also, other threads also read it without proper syncronization (e.g. checkIfOptionsConflict, reportForCurrentOp). This can lead to data races. This same pattern is repeated on all ShardingDDLCoordinators.

To solve it we could synchronize access to the in-memory state with a mutex, similarly to what was done on SERVER-54300. In this case, we need to make sure that writing the document to disk is not done with the mutex held (see SERVER-53996).



 Comments   
Comment by Githook User [ 02/Jun/22 ]

Author:

{'name': 'Enrico Golfieri', 'email': 'enrico.golfieri@mongodb.com', 'username': 'enricogolfieri'}

Message: SERVER-62432 Ensure safe access to ShardingDDLCoordinator instance state documents

(cherry picked from commit c4522f8d57ded742ff66a303fb264f517c06502a)
Branch: v6.0
https://github.com/mongodb/mongo/commit/42f0d7d83d2b7c297202c51cbe186dae2be61348

Comment by Githook User [ 30/May/22 ]

Author:

{'name': 'Enrico Golfieri', 'email': 'enrico.golfieri@mongodb.com', 'username': 'enricogolfieri'}

Message: SERVER-62432 Ensure safe access to ShardingDDLCoordinator instance state documents
Branch: v5.0
https://github.com/mongodb/mongo/commit/92ec456ea23f15a40882b9c96177300543b5c4ad

Comment by Githook User [ 10/May/22 ]

Author:

{'name': 'Enrico Golfieri', 'email': 'enrico.golfieri@mongodb.com', 'username': 'enricogolfieri'}

Message: SERVER-62432 Ensure safe access to ShardingDDLCoordinator instance state documents
Branch: master
https://github.com/mongodb/mongo/commit/c4522f8d57ded742ff66a303fb264f517c06502a

Comment by Max Hirschhorn [ 13/Apr/22 ]

Small note that RefineCollectionShardKeyCoordinator having this same issue came up in SERVER-65500.

Comment by Pierlauro Sciarelli [ 21/Mar/22 ]

The same erroneous pattern is also implemented for rename participants.

Comment by Cris Insignares Cuello [ 20/Jan/22 ]

jordi.serra-torrens can you take a look at this and fix the known cases.

Generated at Thu Feb 08 05:55:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.