[SERVER-76448] Data race on rename collection participant Created: 24/Apr/23  Updated: 29/Oct/23  Resolved: 26/Apr/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 5.0.0, 6.0.0, 7.0.0-rc0
Fix Version/s: 7.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Silvia Surroca Assignee: Silvia Surroca
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Sharding EMEA 2023-05-01
Participants:
Linked BF Score: 135

 Description   

When shardsvr_rename_collection_participant command is called, first it calls getOrCreate, which returns an instance of a {{renameCollectionParticipant }}running asynchronously, then it checks if the parameters of the request are the same than the parameters of the given instance (to ensure idempotency).

Since the check is done while the renameCollectionParticipant is being executed on another thread, there is a data race over _doc attribute:

 

CONSEQUENCES OF THE BUG:

In case of reading a defective _doc value due to a data race the DDL coordinator will retry the command here.

 

A suggestion to fix this bug is to add a const attribute (which could be called _request) and initiate it on the constructor using the _doc value, similar to what RenameCollectionCoordinator already does (1) (2).



 Comments   
Comment by Githook User [ 26/Apr/23 ]

Author:

{'name': 'Silvia Surroca', 'email': 'silvia.surroca@mongodb.com', 'username': 'silviasuhu'}

Message: SERVER-76448 Fix race condition on rename collection participant service
Branch: master
https://github.com/mongodb/mongo/commit/ab714adf0e71005e00ed42367f41ba864b4e6170

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