From 29497d3d585581d97bd28e90d995f14470cc9b93 Mon Sep 17 00:00:00 2001 From: ali-mir Date: Mon, 25 Oct 2021 16:56:41 +0000 Subject: SERVER-60869 Re-add logic to set feature compatibility version on arbiters (cherry picked from commit f094005b0b8a878bc039ddae540b8696f70848f7) --- .../arbiter_always_has_latest_fcv.js | 25 ++++++++++++++++++++++ src/mongo/db/repl/replication_coordinator_impl.cpp | 9 ++++++++ 2 files changed, 34 insertions(+) create mode 100644 jstests/multiVersion/genericSetFCVUsage/arbiter_always_has_latest_fcv.js diff --git a/jstests/multiVersion/genericSetFCVUsage/arbiter_always_has_latest_fcv.js b/jstests/multiVersion/genericSetFCVUsage/arbiter_always_has_latest_fcv.js new file mode 100644 index 00000000000..0e4d2fde530 --- /dev/null +++ b/jstests/multiVersion/genericSetFCVUsage/arbiter_always_has_latest_fcv.js @@ -0,0 +1,25 @@ +/* + * Tests that an arbiter will default to the latest FCV regardless of the FCV of the replica set. + */ +(function() { +"use strict"; + +function runTest(FCV) { + let rst = new ReplSetTest( + {nodes: [{}, {rsConfig: {arbiterOnly: true}}], nodeOpts: {binVersion: FCV}}); + rst.startSet(); + rst.initiate(); + + const arbiter = rst.getArbiter(); + const res = assert.commandWorked( + arbiter.getDB("admin").runCommand({getParameter: 1, featureCompatibilityVersion: 1})); + assert.eq(res.featureCompatibilityVersion.version, latestFCV, tojson(res)); + rst.stopSet(); +} + +runTest(latestFCV); +runTest(lastLTSFCV); +if (lastContinuousFCV != lastLTSFCV) { + runTest(lastContinuousFCV); +} +}()); diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index edd4a533241..a39a9dd61db 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -4345,6 +4345,15 @@ ReplicationCoordinatorImpl::_updateMemberStateFromTopologyCoordinator(WithLock l "Replica set state transition", "newState"_attr = newState, "oldState"_attr = _memberState); + + // Initializes the featureCompatibilityVersion to the latest value, because arbiters do not + // receive the replicated version. This is to avoid bugs like SERVER-32639. + if (newState.arbiter()) { + // (Generic FCV reference): This FCV check should exist across LTS binary versions. + serverGlobalParams.mutableFeatureCompatibility.setVersion( + multiversion::GenericFCV::kLatest); + } + _memberState = newState; _cancelAndRescheduleElectionTimeout_inlock(); -- cgit v1.2.3