Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-67234

Ban uses of FCV constants for FCV checks

    • Replication
    • Fully Compatible
    • Repl 2023-04-17

      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)

            Assignee:
            jiawei.yang@mongodb.com Jiawei Yang
            Reporter:
            huayu.ouyang@mongodb.com Huayu Ouyang
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: