[SERVER-84365] Fix race caused by concurrent reads and writes to serverGlobalParams.clusterRole in unit tests Created: 21/Dec/23  Updated: 22/Dec/23  Resolved: 22/Dec/23

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

Type: Task Priority: Major - P3
Reporter: Cheahuychou Mao Assignee: Cheahuychou Mao
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Backwards Compatibility: Fully Compatible
Participants:
Linked BF Score: 139

 Description   

The race was introduced as part of SERVER-82751 because every time we create a Client, we read serverGlobalParams.clusterRole to check if is a router client. This is safe in production since serverGlobalParams.clusterRole is only set during startup. However, it is causing race in unit tests because we deliberately set serverGlobalParams.clusterRole to whatever each unit test needs to do the testing. Given that Session::isFromRouterPort() can only be true when the transport layer has a router port which can only be true on a mongod with RouterServer role. There is no need to the roles in addition to check isFromRouterPort() when creating a Client, especially since it causes races in a lot of unit tests which would require a lot of effort to rewrite to avoid the race.



 Comments   
Comment by Githook User [ 21/Dec/23 ]

Author:

{'name': 'Cheahuychou Mao', 'email': 'mao.cheahuychou@gmail.com', 'username': 'cheahuychou'}

Message: SERVER-84365 Fix race caused by concurrent reads and writes to serverGlobalParams.clusterRole in unit tests (#17723)

GitOrigin-RevId: 01e7388d7bb917a3543f6800063ec2377f0caa30
Branch: master
https://github.com/mongodb/mongo/commit/8c7d00c6d6b6a26f674286dd268f5938494c913c

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