summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/multiVersion/genericSetFCVUsage/arbiter_always_has_latest_fcv.js25
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp9
2 files changed, 34 insertions, 0 deletions
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();