0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-49060: updating generic FCV constants

This commit is contained in:
Grace Luong 2020-07-08 21:29:09 +00:00 committed by Evergreen Agent
parent b0b09d66b9
commit a2364e8742
20 changed files with 71 additions and 65 deletions

View File

@ -664,7 +664,7 @@ let testCases = {
whatsmyuri: {skip: "executes locally on mongos (not sent to any remote node)"},
};
commandsRemovedFromMongosIn46.forEach(function(cmd) {
commandsRemovedFromMongosSinceLastLTS.forEach(function(cmd) {
testCases[cmd] = {skip: "must define test coverage for 4.6 backwards compatibility"};
});
@ -688,14 +688,15 @@ assert.commandWorked(listCommandsRes);
// After iterating through all the existing commands, ensure there were no additional test cases
// that did not correspond to any mongos command.
for (let key of Object.keys(testCases)) {
// We have defined real test cases for commands added in 4.6 so that the test cases are
// exercised in the regular suites, but because these test cases can't run in the last
// stable suite, we skip processing them here to avoid failing the below assertion.
// We have defined "skip" test cases for commands removed in 4.6 so the test case is defined
// in last stable suites (in which these commands still exist on the mongos), but these test
// cases won't be run in regular suites, so we skip processing them below as well.
if (commandsAddedToMongosIn46.includes(key) ||
commandsRemovedFromMongosIn46.includes(key)) {
// We have defined real test cases for commands added since the last LTS version so that the
// test cases are exercised in the regular suites, but because these test cases can't run in
// the last stable suite, we skip processing them here to avoid failing the below assertion.
// We have defined "skip" test cases for commands removed since the last LTS version so the
// test case is defined in last stable suites (in which these commands still exist on the
// mongos), but these test cases won't be run in regular suites, so we skip processing them
// below as well.
if (commandsAddedToMongosSinceLastLTS.includes(key) ||
commandsRemovedFromMongosSinceLastLTS.includes(key)) {
continue;
}
assert(testCases[key].validated || testCases[key].conditional,

View File

@ -1,9 +1,10 @@
// These commands were removed from mongod in 4.6, but will still appear in the listCommands output
// of a 4.4 mongod. To increase test coverage and allow us to run on same- and
// mixed-version suites, we allow these commands to have a test defined without always existing on
// the servers being used.
const commandsRemovedFromMongodIn46 = ["_configsvrCreateCollection", "mapreduce.shardedfinish"];
// These commands were added in mongod 4.6, so will not appear in the listCommands output of a
// 4.4 mongod. We will allow these commands to have a test defined without always existing on the
// mongod being used.
const commandsAddedToMongodIn46 = [];
// These commands were removed from mongod since the last LTS version, but will still appear in the
// listCommands output of a last LTS version mongod. To increase test coverage and allow us
// to run on same- and mixed-version suites, we allow these commands to have a test defined without
// always existing on the servers being used.
const commandsRemovedFromMongodSinceLastLTS =
["_configsvrCreateCollection", "mapreduce.shardedfinish"];
// These commands were added in mongod since the last LTS version, so will not appear in the
// listCommands output of a last LTS version mongod. We will allow these commands to have a
// test defined without always existing on the mongod being used.
const commandsAddedToMongodSinceLastLTS = [];

View File

@ -1,10 +1,10 @@
// These commands were removed from mongos 4.6, but will still appear in the listCommands output
// of a 4.4 mongos. A last-stable mongos will be unable to run a command on a latest version shard
// that no longer supports that command. To increase test coverage and allow us to run on same- and
// mixed-version suites, we allow these commands to have a test defined without always existing on
// the servers being used.
const commandsRemovedFromMongosIn46 = [];
// These commands were added in mongos 4.6, so will not appear in the listCommands output of a
// 4.4 mongos. We will allow these commands to have a test defined without always existing on the
// mongos being used.
const commandsAddedToMongosIn46 = ["reshardCollection"];
// These commands were removed from mongos since the last LTS version, but will still appear in the
// listCommands output of a last LTS version mongos. A last-stable mongos will be unable to
// run a command on a latest version shard that no longer supports that command. To increase test
// coverage and allow us to run on same- and mixed-version suites, we allow these commands to have a
// test defined without always existing on the servers being used.
const commandsRemovedFromMongosSinceLastLTS = [];
// These commands were added in mongos since the last LTS version, so will not appear in the
// listCommands output of a last LTS version mongos. We will allow these commands to have a test
// defined without always existing on the mongos being used.
const commandsAddedToMongosSinceLastLTS = ["reshardCollection"];

View File

@ -654,7 +654,7 @@ let testCases = {
whatsmyuri: {skip: "internal command"},
};
commandsRemovedFromMongodIn46.forEach(function(cmd) {
commandsRemovedFromMongodSinceLastLTS.forEach(function(cmd) {
testCases[cmd] = {skip: "must define test coverage for 4.4 backwards compatibility"};
});

View File

@ -308,7 +308,7 @@ let testCases = {
whatsmyuri: {skip: "does not return user data"}
};
commandsRemovedFromMongosIn46.forEach(function(cmd) {
commandsRemovedFromMongosSinceLastLTS.forEach(function(cmd) {
testCases[cmd] = {skip: "must define test coverage for 4.4 backwards compatibility"};
});

View File

@ -380,7 +380,7 @@ let testCases = {
whatsmyuri: {skip: "does not return user data"}
};
commandsRemovedFromMongosIn46.forEach(function(cmd) {
commandsRemovedFromMongosSinceLastLTS.forEach(function(cmd) {
testCases[cmd] = {skip: "must define test coverage for 4.4 backwards compatibility"};
});

View File

@ -315,7 +315,7 @@ let testCases = {
whatsmyuri: {skip: "does not return user data"}
};
commandsRemovedFromMongosIn46.forEach(function(cmd) {
commandsRemovedFromMongosSinceLastLTS.forEach(function(cmd) {
testCases[cmd] = {skip: "must define test coverage for 4.4 backwards compatibility"};
});

View File

@ -203,14 +203,13 @@ StatusWith<CollModRequest> parseCollModRequest(OperationContext* opCtx,
// Save this to a variable to avoid reading the atomic variable multiple times.
const auto currentFCV = serverGlobalParams.featureCompatibility.getVersion();
// If the feature compatibility version is not 4.6, and we are validating features as
// master, ban the use of new agg features introduced in 4.6 to prevent them from being
// persisted in the catalog.
// If the feature compatibility version is not kLatest, and we are validating features
// as master, ban the use of new agg features introduced in kLatest to prevent them from
// being persisted in the catalog.
boost::optional<ServerGlobalParams::FeatureCompatibility::Version>
maxFeatureCompatibilityVersion;
if (serverGlobalParams.validateFeaturesAsMaster.load() &&
currentFCV !=
ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo46) {
currentFCV != ServerGlobalParams::FeatureCompatibility::kLatest) {
maxFeatureCompatibilityVersion = currentFCV;
}
cmr.collValidator = coll->parseValidator(opCtx,

View File

@ -842,11 +842,11 @@ Status DatabaseImpl::userCreateNS(OperationContext* opCtx,
// Save this to a variable to avoid reading the atomic variable multiple times.
const auto currentFCV = serverGlobalParams.featureCompatibility.getVersion();
// If the feature compatibility version is not 4.6, and we are validating features as
// master, ban the use of new agg features introduced in 4.6 to prevent them from being
// If the feature compatibility version is not kLatest, and we are validating features as
// master, ban the use of new agg features introduced in kLatest to prevent them from being
// persisted in the catalog.
if (serverGlobalParams.validateFeaturesAsMaster.load() &&
currentFCV != ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo46) {
currentFCV != ServerGlobalParams::FeatureCompatibility::kLatest) {
expCtx->maxFeatureCompatibilityVersion = currentFCV;
}

View File

@ -175,13 +175,13 @@ void FeatureCompatibilityVersion::updateMinWireVersion() {
WireSpec& spec = WireSpec::instance();
switch (serverGlobalParams.featureCompatibility.getVersion()) {
case ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo46:
case ServerGlobalParams::FeatureCompatibility::kLatest:
case ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo46:
case ServerGlobalParams::FeatureCompatibility::Version::kDowngradingTo44:
spec.incomingInternalClient.minWireVersion = LATEST_WIRE_VERSION;
spec.outgoing.minWireVersion = LATEST_WIRE_VERSION;
return;
case ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo44:
case ServerGlobalParams::FeatureCompatibility::kLastLTS:
spec.incomingInternalClient.minWireVersion = LATEST_WIRE_VERSION - 1;
spec.outgoing.minWireVersion = LATEST_WIRE_VERSION - 1;
return;
@ -196,7 +196,7 @@ void FeatureCompatibilityVersion::_setVersion(
serverGlobalParams.featureCompatibility.setVersion(newVersion);
updateMinWireVersion();
if (newVersion != ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo44) {
if (newVersion != ServerGlobalParams::FeatureCompatibility::kLastLTS) {
// Close all incoming connections from internal clients with binary versions lower than
// ours.
opCtx->getServiceContext()->getServiceEntryPoint()->endAllSessions(
@ -207,7 +207,7 @@ void FeatureCompatibilityVersion::_setVersion(
.dropConnections(transport::Session::kKeepOpen);
}
if (newVersion != ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo46) {
if (newVersion != ServerGlobalParams::FeatureCompatibility::kLatest) {
if (MONGO_unlikely(hangBeforeAbortingRunningTransactionsOnFCVDowngrade.shouldFail())) {
LOGV2(20460,
"FeatureCompatibilityVersion - "
@ -228,7 +228,7 @@ void FeatureCompatibilityVersion::_setVersion(
// 1. Setting featureCompatibilityVersion from downgrading to fullyDowngraded.
// 2. Setting featureCompatibilityVersion from fullyDowngraded to upgrading.
const auto shouldIncrementTopologyVersion =
newVersion == ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo44 ||
newVersion == ServerGlobalParams::FeatureCompatibility::kLastLTS ||
newVersion == ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo46;
if (isReplSet && shouldIncrementTopologyVersion) {
replCoordinator->incrementTopologyVersion();
@ -317,7 +317,7 @@ void FeatureCompatibilityVersionParameter::append(OperationContext* opCtx,
BSONObjBuilder featureCompatibilityVersionBuilder(b.subobjStart(name));
switch (serverGlobalParams.featureCompatibility.getVersion()) {
case ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo46:
case ServerGlobalParams::FeatureCompatibility::kLatest:
featureCompatibilityVersionBuilder.append(
FeatureCompatibilityVersionParser::kVersionField,
FeatureCompatibilityVersionParser::kVersion46);
@ -338,7 +338,7 @@ void FeatureCompatibilityVersionParameter::append(OperationContext* opCtx,
FeatureCompatibilityVersionParser::kTargetVersionField,
FeatureCompatibilityVersionParser::kVersion44);
return;
case ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo44:
case ServerGlobalParams::FeatureCompatibility::kLastLTS:
featureCompatibilityVersionBuilder.append(
FeatureCompatibilityVersionParser::kVersionField,
FeatureCompatibilityVersionParser::kVersion44);

View File

@ -1087,8 +1087,8 @@ void InitialSyncer::_fcvFetcherCallback(const StatusWith<Fetcher::QueryResponse>
auto version = fCVParseSW.getValue();
// Changing the featureCompatibilityVersion during initial sync is unsafe.
if (version > ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo44 &&
version < ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo46) {
if (version > ServerGlobalParams::FeatureCompatibility::kLastLTS &&
version < ServerGlobalParams::FeatureCompatibility::kLatest) {
onCompletionGuard->setResultAndCancelRemainingWork_inlock(
lock,
Status(ErrorCodes::IncompatibleServerVersion,

View File

@ -127,7 +127,7 @@ void OplogApplierImplTest::setUp() {
// test fixture does not create a featureCompatibilityVersion document from which to initialize
// the server parameter.
serverGlobalParams.featureCompatibility.setVersion(
ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo46);
ServerGlobalParams::FeatureCompatibility::kLatest);
// This is necessary to generate ghost timestamps for index builds that are not 0, since 0 is an
// invalid timestamp.

View File

@ -339,14 +339,15 @@ StatusWith<ShardType> ShardingCatalogManager::_validateHostAsShard(
<< connectionString.toString() << " as a shard");
}
if (serverGlobalParams.featureCompatibility.getVersion() >
ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo44) {
// If the cluster's FCV is 4.6, or upgrading to / downgrading from, the node being added
// must be a v4.6 binary.
ServerGlobalParams::FeatureCompatibility::kLastLTS) {
// If the cluster's FCV is kLatest, or upgrading to / downgrading from, the node being added
// must be a version kLatest binary.
invariant(maxWireVersion == WireVersion::LATEST_WIRE_VERSION);
} else {
// If the cluster's FCV is 4.4, the node being added must be a v4.4 or v4.6 binary.
// If the cluster's FCV is kLastLTS, the node being added must be a version kLastLTS or
// version kLatest binary.
invariant(serverGlobalParams.featureCompatibility.getVersion() ==
ServerGlobalParams::FeatureCompatibility::Version::kFullyDowngradedTo44);
ServerGlobalParams::FeatureCompatibility::kLastLTS);
invariant(maxWireVersion >= WireVersion::LATEST_WIRE_VERSION - 1);
}
@ -651,7 +652,7 @@ StatusWith<std::string> ShardingCatalogManager::addShard(
BSONObj setFCVCmd;
switch (serverGlobalParams.featureCompatibility.getVersion()) {
case ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo46:
case ServerGlobalParams::FeatureCompatibility::kLatest:
case ServerGlobalParams::FeatureCompatibility::Version::kUpgradingTo46:
setFCVCmd = BSON(FeatureCompatibilityVersionCommandParser::kCommandName
<< FeatureCompatibilityVersionParser::kVersion46

View File

@ -138,7 +138,7 @@ ShardingMongodTestFixture::ShardingMongodTestFixture() {
// Set the highest FCV because otherwise it defaults to the lower FCV. This way we default to
// testing this release's code, not backwards compatibility code.
serverGlobalParams.featureCompatibility.setVersion(
ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo46);
ServerGlobalParams::FeatureCompatibility::kLatest);
}
ShardingMongodTestFixture::~ShardingMongodTestFixture() = default;

View File

@ -198,6 +198,10 @@ struct ServerGlobalParams {
kFullyUpgradedTo46 = 4,
};
static constexpr Version kLatest = Version::kFullyUpgradedTo46;
static constexpr Version kLastContinuous = Version::kFullyDowngradedTo44;
static constexpr Version kLastLTS = Version::kFullyDowngradedTo44;
/**
* On startup, the featureCompatibilityVersion may not have been explicitly set yet. This
* exposes the actual state of the featureCompatibilityVersion if it is uninitialized.

View File

@ -331,11 +331,11 @@ StatusWith<stdx::unordered_set<NamespaceString>> ViewCatalog::_validatePipeline(
// Save this to a variable to avoid reading the atomic variable multiple times.
auto currentFCV = serverGlobalParams.featureCompatibility.getVersion();
// If the feature compatibility version is not 4.6, and we are validating features as master,
// ban the use of new agg features introduced in 4.6 to prevent them from being persisted in the
// catalog.
// If the feature compatibility version is not kLatest, and we are validating features as
// master, ban the use of new agg features introduced in kLatest to prevent them from being
// persisted in the catalog.
if (serverGlobalParams.validateFeaturesAsMaster.load() &&
currentFCV != ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo46) {
currentFCV != ServerGlobalParams::FeatureCompatibility::kLatest) {
expCtx->maxFeatureCompatibilityVersion = currentFCV;
}

View File

@ -180,7 +180,7 @@ int dbtestsMain(int argc, char** argv) {
mongo::runGlobalInitializersOrDie(std::vector<std::string>(argv, argv + argc));
serverGlobalParams.featureCompatibility.setVersion(
ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo46);
ServerGlobalParams::FeatureCompatibility::kLatest);
repl::ReplSettings replSettings;
replSettings.setOplogSizeBytes(10 * 1024 * 1024);
setGlobalServiceContext(ServiceContext::make());

View File

@ -904,7 +904,7 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(SetFeatureCompatibilityVersionLatest,
("EndStartupOptionStorage"))
(InitializerContext* context) {
serverGlobalParams.featureCompatibility.setVersion(
ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo46);
ServerGlobalParams::FeatureCompatibility::kLatest);
return Status::OK();
}

View File

@ -120,7 +120,7 @@ MONGO_INITIALIZER_WITH_PREREQUISITES(SetFeatureCompatibilityVersionLatest,
("EndStartupOptionSetup"))
(InitializerContext* context) {
mongo::serverGlobalParams.featureCompatibility.setVersion(
ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo46);
ServerGlobalParams::FeatureCompatibility::kLatest);
return Status::OK();
}

View File

@ -157,7 +157,7 @@ namespace {
// with a meaningful value will trigger failures as of SERVER-32630.
void setUpFCV() {
serverGlobalParams.featureCompatibility.setVersion(
ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo46);
ServerGlobalParams::FeatureCompatibility::kLatest);
}
void tearDownFCV() {
serverGlobalParams.featureCompatibility.reset();