diff options
author | Vishnu Kaushik <vishnu.kaushik@mongodb.com> | 2021-09-01 21:36:37 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-09-01 22:56:22 +0000 |
commit | 1a0f9486eb228065434d439fc417762c33aab4b7 (patch) | |
tree | dfbae9a0391a1a1f04dddade347e418edb1b030e /src/mongo/db/repl | |
parent | 41bb7c7fb877f475f73265fe7c811e4e811ad174 (diff) | |
download | mongo-1a0f9486eb228065434d439fc417762c33aab4b7.tar.gz |
SERVER-58344 Remove ServerGlobalParams::FeatureCompatibility and replace references with generated FCV constants
Diffstat (limited to 'src/mongo/db/repl')
-rw-r--r-- | src/mongo/db/repl/initial_syncer.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/repl/initial_syncer_test.cpp | 26 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_applier_impl_test.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp | 3 | ||||
-rw-r--r-- | src/mongo/db/repl/tenant_migration_recipient_service.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/tenant_migration_recipient_service_test.cpp | 11 |
7 files changed, 26 insertions, 25 deletions
diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp index 27aa7335f65..5820d2e2ab5 100644 --- a/src/mongo/db/repl/initial_syncer.cpp +++ b/src/mongo/db/repl/initial_syncer.cpp @@ -76,6 +76,7 @@ #include "mongo/util/system_clock_source.h" #include "mongo/util/time_support.h" #include "mongo/util/timer.h" +#include "mongo/util/version/releases.h" namespace mongo { namespace repl { @@ -1060,7 +1061,7 @@ void InitialSyncer::_lastOplogEntryFetcherCallbackForBeginApplyingTimestamp( BSONObjBuilder queryBob; queryBob.append("find", NamespaceString::kServerConfigurationNamespace.coll()); auto filterBob = BSONObjBuilder(queryBob.subobjStart("filter")); - filterBob.append("_id", FeatureCompatibilityVersionParser::kParameterName); + filterBob.append("_id", multiversion::kParameterName); filterBob.done(); // As part of reading the FCV, we ensure the source node's all_durable timestamp has advanced // to at least the timestamp of the last optime that we found in the lastOplogEntryFetcher. @@ -1140,7 +1141,7 @@ void InitialSyncer::_fcvFetcherCallback(const StatusWith<Fetcher::QueryResponse> lock, Status(ErrorCodes::IncompatibleServerVersion, str::stream() << "Sync source had unsafe feature compatibility version: " - << FeatureCompatibilityVersionParser::toString(version))); + << multiversion::toString(version))); return; } diff --git a/src/mongo/db/repl/initial_syncer_test.cpp b/src/mongo/db/repl/initial_syncer_test.cpp index d026f108fb1..9661a12cdef 100644 --- a/src/mongo/db/repl/initial_syncer_test.cpp +++ b/src/mongo/db/repl/initial_syncer_test.cpp @@ -74,6 +74,7 @@ #include "mongo/util/fail_point.h" #include "mongo/util/scopeguard.h" #include "mongo/util/str.h" +#include "mongo/util/version/releases.h" #include "mongo/logv2/log.h" #include "mongo/unittest/barrier.h" @@ -666,14 +667,14 @@ void assertFCVRequest(RemoteCommandRequest request) { << request.toString(); ASSERT_EQUALS(NamespaceString::kServerConfigurationNamespace.coll(), request.cmdObj.getStringField("find")); - ASSERT_BSONOBJ_EQ(BSON("_id" << FeatureCompatibilityVersionParser::kParameterName), + ASSERT_BSONOBJ_EQ(BSON("_id" << multiversion::kParameterName), request.cmdObj.getObjectField("filter")); } void InitialSyncerTest::processSuccessfulFCVFetcherResponseLastLTS() { FeatureCompatibilityVersionDocument fcvDoc; // (Generic FCV reference): This FCV reference should exist across LTS binary versions. - fcvDoc.setVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS); + fcvDoc.setVersion(multiversion::GenericFCV::kLastLTS); processSuccessfulFCVFetcherResponse({fcvDoc.toBSON()}); } @@ -1925,7 +1926,7 @@ TEST_F(InitialSyncerTest, InitialSyncerReturnsTooManyMatchingDocumentsWhenFCVFetcherReturnsMultipleDocuments) { FeatureCompatibilityVersionDocument fcvDoc; // (Generic FCV reference): This FCV reference should exist across LTS binary versions. - fcvDoc.setVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS); + fcvDoc.setVersion(multiversion::GenericFCV::kLastLTS); auto docs = {fcvDoc.toBSON(), BSON("_id" << "other")}; @@ -1936,8 +1937,8 @@ TEST_F(InitialSyncerTest, InitialSyncerReturnsIncompatibleServerVersionWhenFCVFetcherReturnsUpgradeTargetVersion) { FeatureCompatibilityVersionDocument fcvDoc; // (Generic FCV reference): This FCV reference should exist across LTS binary versions. - fcvDoc.setVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS); - fcvDoc.setTargetVersion(ServerGlobalParams::FeatureCompatibility::kLatest); + fcvDoc.setVersion(multiversion::GenericFCV::kLastLTS); + fcvDoc.setTargetVersion(multiversion::GenericFCV::kLatest); runInitialSyncWithBadFCVResponse({fcvDoc.toBSON()}, ErrorCodes::IncompatibleServerVersion); } @@ -1945,15 +1946,16 @@ TEST_F(InitialSyncerTest, InitialSyncerReturnsIncompatibleServerVersionWhenFCVFetcherReturnsDowngradeTargetVersion) { FeatureCompatibilityVersionDocument fcvDoc; // (Generic FCV reference): This FCV reference should exist across LTS binary versions. - fcvDoc.setVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS); - fcvDoc.setTargetVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS); - fcvDoc.setPreviousVersion(ServerGlobalParams::FeatureCompatibility::kLatest); + fcvDoc.setVersion(multiversion::GenericFCV::kLastLTS); + fcvDoc.setTargetVersion(multiversion::GenericFCV::kLastLTS); + fcvDoc.setPreviousVersion(multiversion::GenericFCV::kLatest); runInitialSyncWithBadFCVResponse({fcvDoc.toBSON()}, ErrorCodes::IncompatibleServerVersion); } TEST_F(InitialSyncerTest, InitialSyncerReturnsParseErrorWhenFCVFetcherReturnsNoVersion) { - auto docs = {BSON("_id" << FeatureCompatibilityVersionParser::kParameterName << "targetVersion" - << FeatureCompatibilityVersionParser::kLatest)}; + // (Generic FCV reference): This FCV reference should exist across LTS binary versions. + auto docs = {BSON("_id" << multiversion::kParameterName << "targetVersion" + << multiversion::toString(multiversion::GenericFCV::kLatest))}; runInitialSyncWithBadFCVResponse(docs, ((ErrorCodes::Error)40414)); } @@ -1986,7 +1988,7 @@ TEST_F(InitialSyncerTest, InitialSyncerSucceedsWhenFCVFetcherReturnsOldVersion) FeatureCompatibilityVersionDocument fcvDoc; // (Generic FCV reference): This FCV reference should exist across LTS binary versions. - fcvDoc.setVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS); + fcvDoc.setVersion(multiversion::GenericFCV::kLastLTS); processSuccessfulFCVFetcherResponse({fcvDoc.toBSON()}); } @@ -2024,7 +2026,7 @@ TEST_F( // This is what we want to test. // (Generic FCV reference): This FCV reference should exist across LTS binary versions. FeatureCompatibilityVersionDocument fcvDoc; - fcvDoc.setVersion(ServerGlobalParams::FeatureCompatibility::kLastLTS); + fcvDoc.setVersion(multiversion::GenericFCV::kLastLTS); _mock ->expect([](auto& request) { return request["find"].str() == "system.version"; }, makeCursorResponse( diff --git a/src/mongo/db/repl/oplog.cpp b/src/mongo/db/repl/oplog.cpp index 27d7901157d..1c48b3efd87 100644 --- a/src/mongo/db/repl/oplog.cpp +++ b/src/mongo/db/repl/oplog.cpp @@ -1153,7 +1153,7 @@ Status applyOperation_inlock(OperationContext* opCtx, requestNss == NamespaceString::kServerConfigurationNamespace) { std::string oID; auto status = bsonExtractStringField(o, "_id", &oID); - if (status.isOK() && oID == FeatureCompatibilityVersionParser::kParameterName) { + if (status.isOK() && oID == multiversion::kParameterName) { return Status(ErrorCodes::OplogOperationUnsupported, str::stream() << "Applying operation on feature compatibility version " "document not supported in initial sync: " diff --git a/src/mongo/db/repl/oplog_applier_impl_test.cpp b/src/mongo/db/repl/oplog_applier_impl_test.cpp index eef15241e05..9996da62a0e 100644 --- a/src/mongo/db/repl/oplog_applier_impl_test.cpp +++ b/src/mongo/db/repl/oplog_applier_impl_test.cpp @@ -2366,7 +2366,7 @@ TEST_F(OplogApplierImplTest, FailOnInsertFCVDocument) { ReplicationCoordinator::get(_opCtx.get())->setFollowerMode(MemberState::RS_RECOVERING)); auto op = makeInsertDocumentOplogEntry( - nextOpTime(), fcvNS, BSON("_id" << FeatureCompatibilityVersionParser::kParameterName)); + nextOpTime(), fcvNS, BSON("_id" << multiversion::kParameterName)); ASSERT_EQUALS(runOpInitialSync(op), ErrorCodes::OplogOperationUnsupported); } diff --git a/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp b/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp index 9a2bc34390f..676622692c4 100644 --- a/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp +++ b/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp @@ -176,8 +176,7 @@ void OplogApplierImplTest::setUp() { // test fixture does not create a featureCompatibilityVersion document from which to initialize // the server parameter. // (Generic FCV reference): This FCV reference should exist across LTS binary versions. - serverGlobalParams.mutableFeatureCompatibility.setVersion( - ServerGlobalParams::FeatureCompatibility::kLatest); + serverGlobalParams.mutableFeatureCompatibility.setVersion(multiversion::GenericFCV::kLatest); // This is necessary to generate ghost timestamps for index builds that are not 0, since 0 is an // invalid timestamp. diff --git a/src/mongo/db/repl/tenant_migration_recipient_service.cpp b/src/mongo/db/repl/tenant_migration_recipient_service.cpp index e996689c44b..18f89eb2eb3 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_service.cpp +++ b/src/mongo/db/repl/tenant_migration_recipient_service.cpp @@ -1901,7 +1901,7 @@ void TenantMigrationRecipientService::Instance::_compareRecipientAndDonorFCV() c auto donorFCVbson = _client->findOne(NamespaceString::kServerConfigurationNamespace.ns(), - BSON("_id" << FeatureCompatibilityVersionParser::kParameterName), + BSON("_id" << multiversion::kParameterName), Query(), nullptr, QueryOption_SecondaryOk, diff --git a/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp b/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp index 0b44a1155f3..a303a3cc442 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp +++ b/src/mongo/db/repl/tenant_migration_recipient_service_test.cpp @@ -445,9 +445,9 @@ protected: * Sets the FCV on the donor so that it can respond to FCV requests appropriately. * (Generic FCV reference): This FCV reference should exist across LTS binary versions. */ - void setDonorFCV(const TenantMigrationRecipientService::Instance* instance, - ServerGlobalParams::FeatureCompatibility::Version version = - ServerGlobalParams::FeatureCompatibility::kLatest) { + void setDonorFCV( + const TenantMigrationRecipientService::Instance* instance, + multiversion::FeatureCompatibilityVersion version = multiversion::GenericFCV::kLatest) { auto fcvDoc = FeatureCompatibilityVersionDocument(version); auto client = getClient(instance); client->insert(NamespaceString::kServerConfigurationNamespace.ns(), fcvDoc.toBSON()); @@ -3203,8 +3203,7 @@ TEST_F(TenantMigrationRecipientServiceTest, // Add an FCV value as if it was from a previous attempt, making sure we set a different // version from the one we currently have. // (Generic FCV reference): This FCV reference should exist across LTS binary versions. - initialStateDocument.setRecipientPrimaryStartingFCV( - ServerGlobalParams::FeatureCompatibility::kLastLTS); + initialStateDocument.setRecipientPrimaryStartingFCV(multiversion::GenericFCV::kLastLTS); // Create and start the instance. auto opCtx = makeOperationContext(); @@ -3257,7 +3256,7 @@ TEST_F(TenantMigrationRecipientServiceTest, // Set the donor FCV to be different from 'latest'. // (Generic FCV reference): This FCV reference should exist across LTS binary versions. connFp->waitForTimesEntered(initialTimesEntered + 1); - setDonorFCV(instance.get(), ServerGlobalParams::FeatureCompatibility::kLastContinuous); + setDonorFCV(instance.get(), multiversion::GenericFCV::kLastContinuous); connFp->setMode(FailPoint::off); // Wait for task completion failure. |