@@ -146,33 +146,51 @@ struct ServerGlobalParams {
146146 BSONObj overrideShardIdentity;
147147
148148 struct FeatureCompatibility {
149- enum class Version {
150- /* *
151- * In this mode, the cluster will expose a 3.4-like API. Attempts by a client to use new
152- * features in 3.6 will be rejected.
153- */
154- k34,
155-
156- /* *
157- * In this mode, new features in 3.6 are allowed. The system should guarantee that no
158- * 3.4 node can participate in a cluster whose feature compatibility version is 3.6.
159- */
160- k36,
161- /* *
162- * This is only used for targetVersion to indicate that no upgrade is in progress.
163- */
164- kUnset
165- };
149+ /* *
150+ * The combination of the version and targetVersion determine this node's behavior.
151+ *
152+ * The legal (version, targetVersion) states are:
153+ *
154+ * (3.4, Unset) aka fully 3.4: only 3.4 features are available, and new and existing storage
155+ * engine entries use the 3.4 format
156+ *
157+ * (3.4, 3.6) aka upgrading: only 3.4 features are available, but new storage engine entries
158+ * use the 3.6 format, and existing entries may have either the
159+ * 3.4 or 3.6 format
160+ *
161+ * (3.6, Unset) aka fully 3.6: 3.6 features are available, and new and existing storage
162+ * engine entries use the 3.6 format
163+ *
164+ * (3.4, 3.4) aka downgrading: only 3.4 features are available and new storage engine
165+ * entries use the 3.4 format, but existing entries may have
166+ * either the 3.4 or 3.6 format
167+ */
168+ enum class Version { k34, k36, kUnset };
166169
167- // Read-only parameter featureCompatibilityVersion.
168170 AtomicWord<Version> version{Version::k34};
169171
170172 // If set, an upgrade or downgrade is in progress to the set version.
171173 AtomicWord<Version> targetVersion{Version::kUnset };
172174
175+ const bool isFullyUpgradedTo36 () {
176+ return (version.load () == Version::k36 && targetVersion.load () == Version::kUnset );
177+ }
178+
179+ const bool isUpgradingTo36 () {
180+ return (version.load () == Version::k34 && targetVersion.load () == Version::k36);
181+ }
182+
183+ const bool isFullyDowngradedTo34 () {
184+ return (version.load () == Version::k34 && targetVersion.load () == Version::kUnset );
185+ }
186+
187+ const bool isDowngradingTo34 () {
188+ return (version.load () == Version::k34 && targetVersion.load () == Version::k34);
189+ }
190+
173191 // This determines whether to give Collections UUIDs upon creation.
174- bool isSchemaVersion36 () {
175- return (version. load () == Version::k36 || targetVersion. load () == Version::k36 );
192+ const bool isSchemaVersion36 () {
193+ return (isFullyUpgradedTo36 () || isUpgradingTo36 () );
176194 }
177195
178196 // Feature validation differs depending on the role of a mongod in a replica set or
0 commit comments