summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMisha Tyulenev <misha@mongodb.com>2019-04-18 12:45:32 -0400
committerMisha Tyulenev <misha@mongodb.com>2019-04-18 12:45:32 -0400
commitfe29b62bc82c5455ddae672277227d6e827a90b6 (patch)
treee981cfd85120771951313a6044c5112d7e3404f7
parent16fad378d225c19bafeb6181d532bbca1d117de4 (diff)
downloadmongo-fe29b62bc82c5455ddae672277227d6e827a90b6.tar.gz
SERVER-40136 enable key generator on setting FCV to 3.6
-rw-r--r--jstests/multiVersion/causal_consistency_downgrade_upgrade_rs.js81
-rw-r--r--src/mongo/db/commands/set_feature_compatibility_version_command.cpp4
2 files changed, 85 insertions, 0 deletions
diff --git a/jstests/multiVersion/causal_consistency_downgrade_upgrade_rs.js b/jstests/multiVersion/causal_consistency_downgrade_upgrade_rs.js
new file mode 100644
index 00000000000..9ca4662f73e
--- /dev/null
+++ b/jstests/multiVersion/causal_consistency_downgrade_upgrade_rs.js
@@ -0,0 +1,81 @@
+/**
+ * Test the downgrade of a standalone replica set from latest to last-stable version succeeds,
+ * verifying behavior related to causal consistency at each stage.
+ */
+(function() {
+ "use strict";
+
+ load("jstests/multiVersion/libs/multi_rs.js");
+ load("jstests/multiVersion/libs/causal_consistency_helpers.js");
+
+ var newVersion = "latest";
+ var oldVersion = "last-stable";
+
+ var name = "causal_consistency_rs_downgrade";
+ var rst = new ReplSetTest(
+ {name: name, nodes: 3, waitForKeys: true, nodeOptions: {binVersion: newVersion}});
+ rst.startSet();
+ var replSetConfig = rst.getReplSetConfig();
+ // Hard-code catchup timeout to be compatible with 3.4
+ replSetConfig.settings = {catchUpTimeoutMillis: 2000};
+ rst.initiate(replSetConfig);
+
+ var primary = rst.getPrimary();
+ primary.getDB("test").runCommand({insert: "foo", documents: [{_id: 1, x: 1}]});
+ rst.awaitReplication();
+
+ // Nodes can accept afterClusterTime reads.
+ assert.soonNoExcept(() => {
+ assertContainsLogicalAndOperationTime(primary.getDB("test").runCommand({isMaster: 1}),
+ {initialized: true, signed: false});
+ return true;
+ });
+
+ rst.getSecondaries().forEach(function(secondary) {
+ assert.soonNoExcept(() => {
+ assertContainsLogicalAndOperationTime(secondary.getDB("test").runCommand({isMaster: 1}),
+ {initialized: true, signed: false});
+ return true;
+ });
+ });
+
+ jsTest.log("Setting FCV to 3.4 ...");
+ assert.commandWorked(primary.adminCommand({setFeatureCompatibilityVersion: "3.4"}));
+ rst.awaitReplication();
+
+ // The system keys collection should have been dropped.
+ assertHasNoKeys(rst.getPrimary());
+
+ assertDoesNotContainLogicalOrOperationTime(
+ rst.getPrimary().getDB("test").runCommand({isMaster: 1}));
+
+ rst.getSecondaries().forEach(function(secondary) {
+ assertDoesNotContainLogicalOrOperationTime(
+ secondary.getDB("test").runCommand({isMaster: 1}));
+ });
+
+ jsTest.log("Setting FCV to 3.6 ...");
+
+ assert.commandWorked(rst.getPrimary().adminCommand({setFeatureCompatibilityVersion: "3.6"}));
+ rst.awaitReplication();
+
+ rst.getPrimary().getDB("test").runCommand({insert: "foo", documents: [{_id: 2, x: 1}]});
+ rst.awaitReplication();
+
+ assert.soonNoExcept(() => {
+ assertContainsLogicalAndOperationTime(
+ rst.getPrimary().getDB("test").runCommand({isMaster: 1}),
+ {initialized: true, signed: false});
+ return true;
+ });
+
+ rst.getSecondaries().forEach(function(secondary) {
+ assert.soonNoExcept(() => {
+ assertContainsLogicalAndOperationTime(secondary.getDB("test").runCommand({isMaster: 1}),
+ {initialized: true, signed: false});
+ return true;
+ });
+ });
+
+ rst.stopSet();
+})();
diff --git a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
index 07e12dee765..bae0c8e7d66 100644
--- a/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
+++ b/src/mongo/db/commands/set_feature_compatibility_version_command.cpp
@@ -194,6 +194,10 @@ public:
BSON(FeatureCompatibilityVersion::kCommandName << requestedVersion)))));
}
+ if (LogicalTimeValidator::get(opCtx)) {
+ LogicalTimeValidator::get(opCtx)->enableKeyGenerator(opCtx, true);
+ }
+
if (ShardingState::get(opCtx)->enabled()) {
// Ensure we try reading the keys for signing clusterTime immediately on upgrade.
// Remove after 3.4 -> 3.6 upgrade.