[SERVER-79274] FCV checks can be racy if FCV is uninitialized in between the checks Created: 24/Jul/23  Updated: 16/Nov/23  Resolved: 08/Nov/23

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

Type: Bug Priority: Major - P3
Reporter: Randolph Tan Assignee: Huayu Ouyang
Resolution: Fixed Votes: 0
Labels: repl-shortlist
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
Duplicate
is duplicated by SERVER-82044 Add a method for checking if a featur... Closed
is duplicated by SERVER-82087 FCVServerStatusMetrics::generateSecti... Closed
Problem/Incident
Related
related to SERVER-79317 Provide more documentation and helper... Closed
related to SERVER-80901 Audit gFeatureFlagServerlessChangeStr... Closed
is related to SERVER-82087 FCVServerStatusMetrics::generateSecti... Closed
is related to SERVER-70202 Investigate calling serverGlobalParam... Closed
Assigned Teams:
Replication
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.2, v7.0, v6.0, v5.0, v4.4
Sprint: Repl 2023-09-04, Repl 2023-10-30, Repl 2023-11-13
Participants:
Linked BF Score: 153

 Description   

For places in the codebase where we check the FCV in multiple places, this can be racy. For example, in FeatureFlag::isEnabled,
it performs a check here if fcv is initialized and tries to perform comparison later. However, it is possible for fcv to be reset in between causing the comparison to be perfomed while fcv is not initialized.

And example case where fcv can be uninitialized is when intial sync temporarily resets the value to uninitialized and sets the new value afterwards.

This also applies to FCVServerStatusMetrics::generateSection and other instances where we check if FCV is initialized and then another FCV check that re-gets the FCV.



 Comments   
Comment by Githook User [ 14/Nov/23 ]

Author:

{'name': 'Huayu Ouyang', 'email': 'huayu.ouyang@mongodb.com', 'username': 'huayu-ouyang'}

Message: SERVER-79274 Fix race where FCV is uninitialized in between FCV checks
Branch: v7.0
https://github.com/mongodb/mongo/commit/7ea05af8be392ca95bb2026e74179fbd386ba081

Comment by Githook User [ 14/Nov/23 ]

Author:

{'name': 'Huayu Ouyang', 'email': 'huayu.ouyang@mongodb.com', 'username': 'huayu-ouyang'}

Message: SERVER-79274 Fix race where FCV is uninitialized in between FCV checks

(cherry picked from commit a5da6271d5fd5afb83d0c90a0f641d006862494e)
Branch: v7.2
https://github.com/mongodb/mongo/commit/3884d84f29804eb5702655e9b53d3473c6b0cc8b

Comment by Githook User [ 08/Nov/23 ]

Author:

{'name': 'Huayu Ouyang', 'email': 'huayu.ouyang@mongodb.com', 'username': 'huayu-ouyang'}

Message: SERVER-79274 Fix race where FCV is uninitialized in between FCV checks
Branch: master
https://github.com/mongodb/mongo/commit/a5da6271d5fd5afb83d0c90a0f641d006862494e

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