summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorali-mir <ali.mir@mongodb.com>2021-10-25 16:56:41 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-11-02 15:42:54 +0000
commit29497d3d585581d97bd28e90d995f14470cc9b93 (patch)
treebb60a5271ca9a53feedff0f53f6dc3e349fba02c
parent6dbb7b17909ffd00a54c0e762b6ddfc785e64ba1 (diff)
downloadmongo-29497d3d585581d97bd28e90d995f14470cc9b93.tar.gz
SERVER-60869 Re-add logic to set feature compatibility version on arbitersr5.1.0-rc3
(cherry picked from commit f094005b0b8a878bc039ddae540b8696f70848f7)
-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();