summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2015-12-22 16:15:40 -0500
committerSpencer T Brody <spencer@mongodb.com>2016-01-13 15:44:51 -0500
commitecfe266a47498ba18db62fe97f5d4298c16e23af (patch)
tree0ea6c31f0a44367c89351242ef11d331498b03ad
parent4a9123577a4aac9ab3e14bddb519d61082dc2101 (diff)
downloadmongo-ecfe266a47498ba18db62fe97f5d4298c16e23af.tar.gz
SERVER-20422 SERVER-21995 Allow overriding the cached config server string in SSV after upgrade from SCCC to CSRS
(cherry picked from commit eb140e730ffdcf99f26d9f215dd4391b8978acc9)
-rw-r--r--jstests/sharding/csrs_upgrade.js34
-rw-r--r--src/mongo/db/s/set_shard_version_command.cpp12
2 files changed, 33 insertions, 13 deletions
diff --git a/jstests/sharding/csrs_upgrade.js b/jstests/sharding/csrs_upgrade.js
index c3c044c395a..45db42005e9 100644
--- a/jstests/sharding/csrs_upgrade.js
+++ b/jstests/sharding/csrs_upgrade.js
@@ -42,15 +42,23 @@ var st;
};
/**
- * Runs a config.version read, then splits the data collection and expects both operations to
- * succeed.
+ * Runs several basic operations against a given mongos, including a config.version read,
+ * spliting the data collection, and doing basic crud ops against the data collection, and
+ * expects all operations to succeed.
*/
- var assertCanSplit = function (snode, msg) {
+ var assertOpsWork = function (snode, msg) {
if (msg) {
- jsTest.log("Confirming that " + snode.name + " CAN run a split " + msg);
+ jsTest.log("Confirming that " + snode.name + " CAN run basic sharding ops " + msg);
}
assert(snode.getCollection("config.version").findOne());
assert.commandWorked(runNextSplit(snode));
+
+ // Check that basic crud ops work.
+ var dataColl = snode.getCollection(dataCollectionName);
+ assert.eq(40, dataColl.find().itcount());
+ assert.writeOK(dataColl.insert({_id: 100, x: 1}));
+ assert.writeOK(dataColl.update({_id: 100}, {$inc: {x: 1}}));
+ assert.writeOK(dataColl.remove({x:2}));
};
var waitUntilMaster = function (dnode) {
@@ -129,7 +137,7 @@ var st;
shardcollection: dataCollectionName,
key: { _id: 1 }
}));
- assertCanSplit(st.s0);
+ assert.commandWorked(runNextSplit(st.s0));
assert.commandWorked(st.s0.adminCommand({
moveChunk: dataCollectionName,
find: { _id: 0 },
@@ -164,7 +172,7 @@ var st;
csrs.push(MongoRunner.runMongod(csrs0Opts));
waitUntilMaster(csrs[0]);
- assertCanSplit(st.s0, "using SCCC protocol when first config server is a 1-node replica set");
+ assertOpsWork(st.s0, "using SCCC protocol when first config server is a 1-node replica set");
jsTest.log("Starting new CSRS nodes");
for (var i = 1; i < numCsrsMembers; ++i) {
@@ -181,7 +189,7 @@ var st;
jsTest.log("Splitting a chunk to confirm that the SCCC protocol works w/ 1 rs " +
"node with secondaries");
- assertCanSplit(st.s0, "using SCCC protocol when first config server is primary of " +
+ assertOpsWork(st.s0, "using SCCC protocol when first config server is primary of " +
csrs.length + "-node replica set");
waitUntilAllCaughtUp(csrs);
@@ -241,11 +249,11 @@ var st;
var sconfig = Object.extend({}, st.s0.fullOptions, /* deep */ true);
delete sconfig.port;
sconfig.configdb = csrsName + "/" + csrs[0].name;
- assertCanSplit(MongoRunner.runMongos(sconfig),
- "when mongos started with --configdb=" + sconfig.configdb);
+ assertOpsWork(MongoRunner.runMongos(sconfig),
+ "when mongos started with --configdb=" + sconfig.configdb);
sconfig.configdb = st.s0.fullOptions.configdb;
- assertCanSplit(MongoRunner.runMongos(sconfig),
- "when mongos started with --configdb=" + sconfig.configdb);
- assertCanSplit(st.s0, "on mongos that drove the upgrade");
- assertCanSplit(st.s1, "on mongos that was previously unaware of the upgrade");
+ assertOpsWork(MongoRunner.runMongos(sconfig),
+ "when mongos started with --configdb=" + sconfig.configdb);
+ assertOpsWork(st.s0, "on mongos that drove the upgrade");
+ assertOpsWork(st.s1, "on mongos that was previously unaware of the upgrade");
}());
diff --git a/src/mongo/db/s/set_shard_version_command.cpp b/src/mongo/db/s/set_shard_version_command.cpp
index 4606720cb33..e0e691117fe 100644
--- a/src/mongo/db/s/set_shard_version_command.cpp
+++ b/src/mongo/db/s/set_shard_version_command.cpp
@@ -363,6 +363,18 @@ private:
return true;
}
+ if (givenConnStr.type() == ConnectionString::SET &&
+ storedConnStr.type() == ConnectionString::SYNC) {
+ log() << "Detected upgrade from mirrored (SCCC) config servers to "
+ "replica set (CSRS) config servers. setShardVersion was given: "
+ << givenConnStr
+ << " for the config server connection string, but has stored: "
+ << storedConnStr;
+ storedConnStr = givenConnStr;
+
+ return true;
+ }
+
const auto& storedRawConfigString = storedConnStr.toString();
if (storedRawConfigString == configdb) {
return true;