0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-28 07:59:02 +01:00

SERVER-17348 Bump mongos upgrade version for v3.2

This commit is contained in:
Randolph Tan 2015-02-23 10:55:06 -05:00
parent 010b40a018
commit db982c182c
15 changed files with 80 additions and 283 deletions

View File

@ -821,7 +821,7 @@ tasks:
script: |
cp mongodb*/bin/* .
rm -rf /data/install /data/multiversion
${python|python} buildscripts/setup_multiversion_mongodb.py /data/install /data/multiversion "Linux/x86_64" "1.8" "2.0" "2.2" "2.4" "2.6" "3.0.0-rc9"
${python|python} buildscripts/setup_multiversion_mongodb.py /data/install /data/multiversion "Linux/x86_64" "1.8" "2.0" "2.2" "2.4" "2.6" "3.0"
PATH=$PATH:/data/multiversion ${asan_symbolizer} ${python|python} buildscripts/smoke.py --nopreallocj --with-cleanbb --mongod ./mongod --mongo ./mongo --report-file report.json ${test_flags|} --buildlogger-url ${logger_url|http://buildlogs.mongodb.org/} --buildlogger-builder MCI_${build_variant} --buildlogger-buildnum ${builder_num|} --buildlogger-credentials ./mci.buildlogger --buildlogger-phase ${task_name}_${execution} multiVersion
- name: noPassthrough

View File

@ -142,5 +142,5 @@ assert.allBinVersions( versionsToCheck, versionsFound );
jsTest.log("DONE!");
st.stop();
}); // TODO: SERVER-17348 enable again after v3.0 is released.
})();

View File

@ -2,8 +2,6 @@
// Upgrades a cluster to a newer version
//
if (false) { // TODO: SERVER-17348 enable again after v3.0 is released.
load( './jstests/multiVersion/libs/multi_rs.js' )
load( './jstests/multiVersion/libs/multi_cluster.js' )
load( './jstests/libs/test_background_ops.js' )
@ -156,4 +154,3 @@ jsTest.log( "DONE!" )
st.stop()
} // END OUTER LOOP FOR RS CLUSTER
}

View File

@ -46,8 +46,12 @@ ReplSetTest.prototype.upgradeNode = function(node, opts, user, pwd) {
assert.eq(1, node.getDB("admin").auth(user, pwd));
}
assert.commandWorked(node.adminCommand("replSetMaintenance"));
this.waitForState(node, ReplSetTest.State.RECOVERING);
var isMaster = node.getDB('admin').runCommand({ isMaster: 1 });
if (!isMaster.arbiterOnly) {
assert.commandWorked(node.adminCommand("replSetMaintenance"));
this.waitForState(node, ReplSetTest.State.RECOVERING);
}
var newNode = this.restart(node, opts);
if (user != undefined) {

View File

@ -567,7 +567,7 @@ function doMultiThreadedWork(primary, numThreads) {
"use strict";
var name = "mixed_storage_and_version";
// Create a replica set with 2 nodes of each of the types below, plus one arbiter.
var oldVersion = "2.6";
var oldVersion = "last-stable";
var newVersion = "latest";
var setups = [{binVersion: newVersion, storageEngine: 'mmapv1'},
{binVersion: newVersion, storageEngine: 'wiredTiger'},
@ -621,7 +621,7 @@ function doMultiThreadedWork(primary, numThreads) {
catch(e) {
// Expected to fail, as we'll have to reconnect.
}
replTest.awaitReplication();
replTest.awaitReplication(60000); // 2 times the election period.
assert.soon(primaryChanged(conns, replTest, primaryIndex),
"waiting for higher priority primary to be elected", 100000);
print("New primary elected, doing a bunch of work");
@ -631,4 +631,4 @@ function doMultiThreadedWork(primary, numThreads) {
print("Work done, checking to see all nodes match");
assertSameData(primary, conns);
}
}); // TODO: SERVER-17348 enable again after v3.0 is released.
})();

View File

@ -1,5 +1,5 @@
/**
* Tests upgrading a cluster which has 2.6 mongos.
* Tests upgrading a cluster which has 3.0 mongos.
*/
load( './jstests/multiVersion/libs/multi_rs.js' )
@ -15,15 +15,15 @@ var runTest = function(isRSCluster, isSyncCluster) {
jsTest.log( "Starting" + ( isRSCluster ? " (replica set)" : "" ) + " cluster" +
( isSyncCluster ? " (sync)" : "" ) + "..." );
jsTest.log( "Starting 2.4 cluster..." );
jsTest.log( "Starting 2.6 cluster..." );
var options = {
mongosOptions : { binVersion : "2.4" },
configOptions : { binVersion : "2.4" },
shardOptions : { binVersion : "2.4" },
mongosOptions : { binVersion : "2.6" },
configOptions : { binVersion : "2.6" },
shardOptions : { binVersion : "2.6" },
rsOptions : { binVersion : "2.4" /*, oplogSize : 100, smallfiles : null */ },
rsOptions : { binVersion : "2.6" /*, oplogSize : 100, smallfiles : null */ },
separateConfig : true,
sync : isSyncCluster,
@ -39,77 +39,77 @@ var shards = st.s0.getDB("config").shards.find().toArray();
var configConnStr = st._configDB;
//
// Make sure 2.8 mongoses won't start in 2.4 cluster
// Make sure 3.2 mongoses won't start in 2.6 cluster
//
jsTest.log("Starting v2.8 mongos in 2.4 cluster...");
jsTest.log("Starting v3.2 mongos in 2.6 cluster...");
var mongos = MongoRunner.runMongos({ binVersion : "2.8", configdb : configConnStr });
var mongos = MongoRunner.runMongos({ binVersion : "3.2", configdb : configConnStr });
assert.eq(null, mongos);
mongos = MongoRunner.runMongos({ binVersion : "2.8", configdb : configConnStr, upgrade : "" });
mongos = MongoRunner.runMongos({ binVersion : "3.2", configdb : configConnStr, upgrade : "" });
assert.eq(null, mongos);
jsTest.log("2.8 mongoses did not start or upgrade in 2.4 cluster (which is correct).");
jsTest.log("3.2 mongoses did not start or upgrade in 2.6 cluster (which is correct).");
//
// Upgrade 2.4 cluster to 2.4/2.6
// Upgrade 2.6 cluster to 2.6/3.0
//
var configDB = st.s.getDB('config');
var clusterID = configDB.getCollection('version').findOne().clusterId;
jsTest.log("Upgrading 2.4 cluster to 2.4/2.6 cluster...");
jsTest.log("Upgrading 2.6 cluster to 2.6/3.0 cluster...");
// upgrade config to v4 (This is a required to make 2.6 mongos startable).
mongos = MongoRunner.runMongos({ binVersion : "2.6", configdb : configConnStr, upgrade : "" });
// upgrade config to v4 (This is a required to make 3.0 mongos startable).
mongos = MongoRunner.runMongos({ binVersion : "3.0", configdb : configConnStr, upgrade : "" });
assert.eq(null, mongos);
var version = configDB.getCollection('version').findOne();
printjson(version);
assert.eq(version.minCompatibleVersion, 4);
assert.eq(version.currentVersion, 5);
assert.eq(version.minCompatibleVersion, 5);
assert.eq(version.currentVersion, 6);
assert.eq(clusterID, version.clusterId); // clusterId shouldn't change
assert.eq(version.excluding, undefined);
st.upgradeCluster(MongoRunner.versionIterator(["2.4","2.6"]));
st.upgradeCluster(MongoRunner.versionIterator(["2.6","3.0"]));
// Restart of mongos here is unfortunately necessary, connection pooling otherwise causes problems
st.restartMongoses();
//
// Make sure 2.8 mongoses won't start in 2.4/2.6 cluster
// Make sure 3.2 mongoses won't start in 2.6/3.0 cluster
//
jsTest.log("Starting v2.8 mongos in 2.4/2.6 cluster....");
jsTest.log("Starting v3.2 mongos in 2.6/3.0 cluster....");
mongos = MongoRunner.runMongos({ binVersion : "2.8", configdb : configConnStr });
mongos = MongoRunner.runMongos({ binVersion : "3.2", configdb : configConnStr });
assert.eq(null, mongos);
jsTest.log("2.8 mongoses did not start or upgrade in 2.4/2.6 cluster (which is correct).");
jsTest.log("3.2 mongoses did not start or upgrade in 2.6/3.0 cluster (which is correct).");
//
// Upgrade 2.4/2.6 cluster to only 2.6
// Upgrade 2.6/3.0 cluster to only 3.0
//
jsTest.log("Upgrading 2.4/2.6 cluster to 2.6 cluster...");
jsTest.log("Upgrading 2.6/3.0 cluster to 3.0 cluster...");
st.upgradeCluster("2.6");
st.upgradeCluster("3.0");
st.restartMongoses();
//
// Make sure 2.8 mongoses will successfully upgrade in 2.6 cluster
// Make sure 3.2 mongoses will successfully upgrade in 3.0 cluster
//
jsTest.log("Starting v2.8 mongos in 2.6 cluster....");
jsTest.log("Starting v3.2 mongos in 3.0 cluster....");
mongos = MongoRunner.runMongos({ binVersion : "2.8", configdb : configConnStr });
mongos = MongoRunner.runMongos({ binVersion : "3.2", configdb : configConnStr });
assert.eq(null, mongos);
mongos = MongoRunner.runMongos({ binVersion : "2.8", configdb : configConnStr, upgrade : "" });
mongos = MongoRunner.runMongos({ binVersion : "3.2", configdb : configConnStr, upgrade : "" });
assert.eq(null, mongos);
jsTest.log("2.8 mongoses started in 2.6 cluster.");
jsTest.log("3.2 mongoses started in 3.0 cluster.");
//
// Verify cluster version is correct
@ -119,40 +119,22 @@ configDB = st.s.getDB('config'); // Get a new db since a restart happened.
version = configDB.getCollection('version').findOne();
printjson(version);
assert.eq(version.minCompatibleVersion, 5);
assert.eq(version.currentVersion, 6);
assert.eq(version.minCompatibleVersion, 6);
assert.eq(version.currentVersion, 7);
assert.eq(clusterID, version.clusterId); // clusterId shouldn't change
assert.eq(version.excluding, undefined);
//
// Verify that the config.locks { ts: 1 } index is not unique for all config servers.
//
st._configServers.forEach(function(conn) {
var idxList = conn.getDB('config').locks.getIndexes();
var foundIndex = false;
idxList.forEach(function(idxSpec) {
if (bsonWoCompare(idxSpec.key, { ts: 1 }) == 0) {
foundIndex = true;
assert.eq(idxSpec.unique, null);
return;
}
});
assert(foundIndex, '{ ts: 1 } index not found in ' + conn + ': ' + tojson(idxList));
});
// Make sure that you can't run 2.4 mongos
mongos = MongoRunner.runMongos({ binVersion : "2.4", configdb : configConnStr });
// Make sure that you can't run 2.6 mongos
mongos = MongoRunner.runMongos({ binVersion : "2.6", configdb : configConnStr });
assert.eq(null, mongos);
// Make sure that you can run 2.6 mongos
mongos = MongoRunner.runMongos({ binVersion : "2.6", configdb : configConnStr });
// Make sure that you can run 3.0 mongos
mongos = MongoRunner.runMongos({ binVersion : "3.0", configdb : configConnStr });
assert.neq(null, mongos);
MongoRunner.stopMongos(mongos);
// Make sure that you can run 2.8 mongos
mongos = MongoRunner.runMongos({ binVersion : "2.8", configdb : configConnStr });
// Make sure that you can run 3.2 mongos
mongos = MongoRunner.runMongos({ binVersion : "3.2", configdb : configConnStr });
assert.neq(null, mongos);
MongoRunner.stopMongos(mongos);

View File

@ -1,94 +0,0 @@
// Ensures that sane errors are thrown from mongos v2.6 when present in a cluster with mongod v2.8
// shards
// TODO: Remove post v2.8
load('./jstests/multiVersion/libs/multi_rs.js');
load('./jstests/multiVersion/libs/multi_cluster.js');
// Clearing the connection pool deterministically is awkward - the actual command may fail due to
// using the conn pool in order to talk to the config servers
function clearConnPool(mongos) {
"use strict";
assert.soon(function() {
try {
return mongos.adminCommand({connPoolSync : true}).ok;
} catch (ex) {
printjson(ex);
return false;
}
});
}
// Errors are A) currently opaque, and B) wrapped in other error messages, making it awkward to
// detect different codes
function isProtocolError(ex) {
"use strict";
return /15907/.test(ex.toString());
}
function testBadUpgrade(isRSCluster) {
"use strict";
jsTest.log("Starting " + (isRSCluster ? "(replica set)" : "") + " cluster...");
var options = {mongosOptions : {binVersion : "2.6"},
configOptions : {binVersion : "2.6"},
shardOptions : {binVersion : "2.6"},
rsOptions : {binVersion : "2.6", nodes : 2},
separateConfig : true,
sync : false,
rs : isRSCluster};
var st = new ShardingTest({shards : 2, mongos : 1, other : options});
var mongos = st.s0;
var mongosV26 = MongoRunner.runMongos({configdb : st._configDB, binVersion : "2.6"});
mongos.forceWriteMode("commands");
mongosV26.forceWriteMode("commands");
var coll = mongos.getCollection("foo.bar");
var collV26 = mongosV26.getCollection(coll.toString());
// Insert a single document to use later
assert.writeOK(coll.insert({hello : "world"}));
jsTest.log("Upgrading cluster...");
// Upgrade config metadata
// Mongos terminates after upgrading
assert.eq(null, MongoRunner.runMongos({binVersion : "2.8",
configdb : st._configDB,
upgrade : ''}));
// Upgrade cluster binaries
st.upgradeCluster("2.8");
jsTest.log("Cluster upgraded.");
// Flush connection pools to avoid transient connection failures
clearConnPool(mongos);
clearConnPool(mongosV26);
// Queries should succeed v2.8, fail v2.6
assert.neq(null, coll.findOne({}));
try {
collV26.findOne({});
assert(false, "should not be able to query v2.8 shards from v2.6 mongos");
} catch (ex) {
assert(isProtocolError(ex), tojson(ex));
}
// Writes should succeed v2.8, fail v2.6
assert.writeOK(coll.insert({hello : "world"}));
var result = collV26.insert({hello : "world"});
assert.writeError(result);
assert(isProtocolError(result.getWriteError().errmsg));
MongoRunner.stopMongos(mongosV26);
st.stop();
}
testBadUpgrade(false);
testBadUpgrade(true);

View File

@ -89,8 +89,8 @@ jsTest.log("Mongoses stopped...");
printjson(version);
assert.eq(version.minCompatibleVersion, 5);
assert.eq(version.currentVersion, 6);
assert.eq(version.minCompatibleVersion, 6);
assert.eq(version.currentVersion, 7);
assert(version.clusterId);
assert.eq(version.excluding, undefined);

View File

@ -83,8 +83,8 @@ env.CppUnitTest('type_tags_test', 'type_tags_test.cpp',
env.Library('upgrade', ['cluster_client_internal.cpp',
'config_upgrade.cpp',
'config_upgrade_helpers.cpp',
'config_upgrade_v0_to_v6.cpp',
'config_upgrade_v5_to_v6.cpp'],
'config_upgrade_v0_to_v7.cpp',
'config_upgrade_v6_to_v7.cpp'],
LIBDEPS=['base',
'$BUILD_DIR/mongo/mongocommon'])

View File

@ -128,13 +128,13 @@ namespace mongo {
ConfigUpgradeRegistry registry;
// v0 to v6
Upgrade v0ToV6(0, VersionRange(5, 6), doUpgradeV0ToV6);
registry.insert(make_pair(v0ToV6.fromVersion, v0ToV6));
// v0 to v7
Upgrade v0ToV7(0, VersionRange(6, 7), doUpgradeV0ToV7);
registry.insert(make_pair(v0ToV7.fromVersion, v0ToV7));
// v5 to v6
Upgrade v5ToV6(5, VersionRange(5, 6), doUpgradeV5ToV6);
registry.insert(make_pair(v5ToV6.fromVersion, v5ToV6));
// v6 to v7
Upgrade v6ToV7(6, VersionRange(6, 7), doUpgradeV6ToV7);
registry.insert(make_pair(v6ToV7.fromVersion, v6ToV7));
validateRegistry(registry);

View File

@ -113,7 +113,9 @@ namespace mongo {
* specifications.
* + config.locks { ts: 1 } index is no longer unique.
*/
UpgradeHistory_DummyBumpPre2_8 = 6,
UpgradeHistory_DummyBumpPre2_8 = 6, // Note: 2.8 is also known as 3.0.
UpgradeHistory_DummyBumpPre3_0 = 7,
};
//
@ -122,10 +124,10 @@ namespace mongo {
//
// Earliest version we're compatible with
const int MIN_COMPATIBLE_CONFIG_VERSION = UpgradeHistory_DummyBumpPre2_6;
const int MIN_COMPATIBLE_CONFIG_VERSION = UpgradeHistory_DummyBumpPre2_8;
// Latest version we know how to communicate with
const int CURRENT_CONFIG_VERSION = UpgradeHistory_DummyBumpPre2_8;
const int CURRENT_CONFIG_VERSION = UpgradeHistory_DummyBumpPre3_0;
//
// DECLARATION OF UPGRADE FUNCTIONALITY
@ -133,11 +135,11 @@ namespace mongo {
// config_upgrade.cpp::createRegistry()
//
bool doUpgradeV0ToV6(const ConnectionString& configLoc,
bool doUpgradeV0ToV7(const ConnectionString& configLoc,
const VersionType& lastVersionInfo,
std::string* errMsg);
bool doUpgradeV5ToV6(const ConnectionString& configLoc,
bool doUpgradeV6ToV7(const ConnectionString& configLoc,
const VersionType& lastVersionInfo,
std::string* errMsg);

View File

@ -46,11 +46,11 @@ namespace mongo {
using mongo::str::stream;
/**
* Upgrade v0 to v6 described here
* Upgrade v0 to v7 described here
*
* This upgrade takes the config server from empty to an initial version.
*/
bool doUpgradeV0ToV6(const ConnectionString& configLoc,
bool doUpgradeV0ToV7(const ConnectionString& configLoc,
const VersionType& lastVersionInfo,
string* errMsg)
{

View File

@ -44,70 +44,27 @@ namespace mongo {
using std::string;
using std::vector;
static const char* minMongoProcessVersion = "2.6";
static const char* minMongoProcessVersion = "3.0";
static const char* cannotCleanupMessage =
"\n\n"
"******\n"
"Cannot upgrade config database from v5 to v6 because a previous upgrade\n"
"Cannot upgrade config database from v6 to v7 because a previous upgrade\n"
"failed in the critical section. Manual intervention is required to re-sync\n"
"the config servers.\n"
"******\n";
namespace {
/**
* Returns false if the { ts: 1 } unique index does not exist. Returns true if it does
* or cannot confirm that it does due to errors.
*/
bool hasBadIndex(const ConnectionString& configLoc,
string* errMsg) {
const BSONObj lockIdxKey = BSON(LocksType::lockID() << 1);
const NamespaceString indexNS(LocksType::ConfigNS);
vector<HostAndPort> configHosts = configLoc.getServers();
for (vector<HostAndPort>::const_iterator configIter = configHosts.begin();
configIter != configHosts.end(); ++configIter) {
list<BSONObj> indexSpecs;
try {
ScopedDbConnection conn(*configIter);
indexSpecs = conn->getIndexSpecs(indexNS);
conn.done();
}
catch (const DBException& ex) {
*errMsg = str::stream() << "error while checking { ts: 1 } index"
<< causedBy(ex);
return true;
}
for (list<BSONObj>::const_iterator idxIter = indexSpecs.begin();
idxIter != indexSpecs.end(); ++idxIter) {
BSONObj indexSpec(*idxIter);
if (indexSpec["key"].Obj().woCompare(lockIdxKey) == 0) {
if (indexSpec["unique"].trueValue()) {
*errMsg = str::stream() << "unique { ts: 1 } index still exists in "
<< configIter->toString();
return true;
}
}
}
}
return false;
}
}
/**
* Upgrades v5 to v6.
* Upgrades v6 to v7.
*/
bool doUpgradeV5ToV6(const ConnectionString& configLoc,
bool doUpgradeV6ToV7(const ConnectionString& configLoc,
const VersionType& lastVersionInfo,
string* errMsg)
{
string dummy;
if (!errMsg) errMsg = &dummy;
verify(lastVersionInfo.getCurrentVersion() == UpgradeHistory_DummyBumpPre2_6);
verify(lastVersionInfo.getCurrentVersion() == UpgradeHistory_DummyBumpPre2_8);
Status result = preUpgradeCheck(configLoc, lastVersionInfo, minMongoProcessVersion);
if (!result.isOK()) {
@ -139,56 +96,6 @@ namespace mongo {
// 6. Rename the backup collection to the name of the original collection with
// dropTarget set to true.
// Make sure the { ts: 1 } index is not unique by dropping the existing one
// and rebuilding the index with the right specification.
const BSONObj lockIdxKey = BSON(LocksType::lockID() << 1);
const NamespaceString indexNS(LocksType::ConfigNS);
bool dropOk = false;
try {
ScopedDbConnection conn(configLoc);
BSONObj dropResponse;
dropOk = conn->runCommand(indexNS.db().toString(),
BSON("dropIndexes" << indexNS.coll()
<< "index" << lockIdxKey),
dropResponse);
conn.done();
}
catch (const DBException& ex) {
if (ex.getCode() == 13105) {
// 13105 is the exception code from SyncClusterConnection::findOne that gets
// thrown when one of the command responses has an "ok" field that is not true.
dropOk = false;
}
else {
*errMsg = str::stream() << "Failed to drop { ts: 1 } index" << causedBy(ex);
return false;
}
}
if (!dropOk && hasBadIndex(configLoc, errMsg)) {
// Fail only if the index still exists.
return false;
}
result = clusterCreateIndex(LocksType::ConfigNS,
BSON(LocksType::lockID() << 1),
false, // unique
NULL);
if (!result.isOK()) {
*errMsg = str::stream() << "error while creating { ts: 1 } index on config db"
<< causedBy(result);
return false;
}
LOG(1) << "Checking to make sure that the right { ts: 1 } index is created...";
if (hasBadIndex(configLoc, errMsg)) {
return false;
}
// We're only after the version bump in commitConfigUpgrade here since we never
// get into the critical section.
Status commitStatus = commitConfigUpgrade(configLoc.toString(),

View File

@ -979,7 +979,7 @@ ReplSetTest.prototype.waitForIndicator = function( node, states, ind, timeout ){
var lastTime = null
var currTime = new Date().getTime()
var status = undefined
var status = undefined;
var self = this;
assert.soon(function() {
@ -988,7 +988,6 @@ ReplSetTest.prototype.waitForIndicator = function( node, states, ind, timeout ){
if (!conn) conn = self.liveNodes.slaves[0];
if (!conn) return false; // Try again to load connection
var status = null;
var getStatusFunc = function() {
status = conn.getDB('admin').runCommand({replSetGetStatus: 1});
};

View File

@ -112,14 +112,14 @@ MongoRunner.VersionSub = function(regex, version) {
// version string to support the dev/stable MongoDB release cycle.
MongoRunner.binVersionSubs = [ new MongoRunner.VersionSub(/^latest$/, ""),
new MongoRunner.VersionSub(/^oldest-supported$/, "1.8"),
// To-be-updated when 3.0 becomes available
new MongoRunner.VersionSub(/^last-stable$/, "2.6"),
// To-be-updated when 3.4 becomes available
new MongoRunner.VersionSub(/^last-stable$/, "3.0"),
// Latest unstable and next stable are effectively the
// same release
new MongoRunner.VersionSub(/^2\.7(\..*){0,1}/, ""),
new MongoRunner.VersionSub(/^2\.8(\..*){0,1}/, ""),
new MongoRunner.VersionSub(/^3\.0(\..*){0,1}/, ""),
new MongoRunner.VersionSub(/^3\.1(\..*){0,1}/, "") ];
// 2.8 and 3.0 are equivalent.
new MongoRunner.VersionSub(/^2\.8(\..*){0,1}/, "3.0"),
new MongoRunner.VersionSub(/^3\.1(\..*){0,1}/, ""),
new MongoRunner.VersionSub(/^3\.2(\..*){0,1}/, "") ];
MongoRunner.getBinVersionFor = function(version) {