[SERVER-85316] FeatureCompatibilityVersion static functions can access uninitialized optional Created: 17/Jan/24  Updated: 05/Feb/24

Status: Open
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: George Wangensteen Assignee: Huayu Ouyang
Resolution: Unresolved Votes: 0
Labels: not-7.3-blocker
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Assigned Teams:
Replication
Operating System: ALL
Sprint: Repl 2024-02-05, Repl 2024-02-19
Participants:
Linked BF Score: 0

 Description   

FeatureCompatibilityVersion::validateSetFeatureCompatibilityVersionRequest calls value() here on a boost::optional<BSONObj> it obtains from FeatureCompatibilityVersion::findFeatureCompatibilityVersionDocument.

findFeatureCompatabilityVersionDocument will return an uninitialized optional here if the underlying StorageInterface->findById fails for any reason (for example, if the opCtx is killed due to repl state change).

If we call value() on the optional when it is uninitialized, it will throw a boost::bad_optional_access exception, which is not caught in the server and will ultimately result in a server crash. We should check if the optional is none and propagate up a correct/useful error to the top layer.

FeatureCompatibilityVersion::updateFeatureCompatibilityVersionDocument seems to have the same problem here


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