[SERVER-67234] Ban uses of FCV constants for FCV checks Created: 13/Jun/22  Updated: 29/Oct/23  Resolved: 14/Apr/23

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

Type: Task Priority: Major - P3
Reporter: Huayu Ouyang Assignee: Jiawei Yang
Resolution: Fixed Votes: 0
Labels: milestone-2, pm-2821-milestone-1
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-66728 Remove Old 5.x FCV Constants Blocked
depends on SERVER-66923 Remove kFullyDowngradedTo_5_0 constan... Closed
depends on SERVER-67235 Change references in pipeline_d.cpp t... Closed
depends on SERVER-67237 Remove FCV constant in document_sourc... Closed
depends on SERVER-67444 Eliminate legacy `requestMoveChunk` c... Closed
is depended on by SERVER-60213 Standardize when to use and remove fe... Closed
Duplicate
is duplicated by SERVER-67243 Add a linter to server_options.h FCV ... Closed
is duplicated by SERVER-61967 Ban usages of transitionary FCVs in F... Closed
Related
related to SERVER-61967 Ban usages of transitionary FCVs in F... Closed
Assigned Teams:
Replication
Backwards Compatibility: Fully Compatible
Sprint: Repl 2023-04-17
Participants:

 Description   

The FCV constants (such as multiversion::FeatureCompatibilityVersion::kVersion_6_0, etc) should not generally not be used in FCV checks like this (i.e. with the isLessThan, isGreaterThan, isLessThanOrEqualTo, isGreaterThanOrEqualTo functions)

We can either do this by making the FCV constants private (preferred) We cannot do this because the FeatureCompatibilityVersion class (not the constants themselves) is used elsewhere, example: https://github.com/mongodb/mongo/blob/c8bfab6325363f696e628ddafaf40df921526560/src/mongo/db/commands/feature_compatibility_version_parser.cpp#L45)

The other option is we can add a linter to ban additional usages or fail compile when an FCV is used as part of a check.

If we add a linter we can consider adding it as a rule in clang-tidy (parsing the C++ AST instead of doing string search, similar to what jstestfuzz does for JavaScript). Another related suggestion is that instead of/in addition to the existing future git tag variant that runs everything, we could extend the clang-tidy rule to change the generic FCV references and remaining explicit FCV checks to use the new FCV (or even fuzz the fcv version)



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

Author:

{'name': 'Jiawei Yang', 'email': 'jiawei.yang@mongodb.com', 'username': 'YoungYang0820'}

Message: SERVER-67234 add clang-tidy rule to ban fcv constant usage in compare
Branch: master
https://github.com/mongodb/mongo/commit/7d5ec88486310a0e4b899fa673fbb7f8a4cf7ab5

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