0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00

SERVER-15767 Refuse to start up with invalid locally stored rs config

This commit is contained in:
Spencer T Brody 2014-10-27 14:25:47 -04:00
parent 4f4a5103f1
commit 33d59e5d8c

View File

@ -191,10 +191,11 @@ namespace {
ReplicaSetConfig localConfig;
Status status = localConfig.initialize(cfg.getValue());
if (!status.isOK()) {
warning() << "Locally stored replica set configuration does not parse; "
"waiting for rsInitiate or remote heartbeat; Got " << status << " while parsing " <<
cfg.getValue();
return true;
error() << "Locally stored replica set configuration does not parse; See "
"http://www.mongodb.org/dochub/core/recover-replica-set-from-invalid-config "
"for information on how to recover from this. Got \"" <<
status << "\" while parsing " << cfg.getValue();
fassertFailedNoTrace(28542);
}
StatusWith<OpTime> lastOpTimeStatus = _externalState->loadLastOpTime(txn);
@ -232,10 +233,20 @@ namespace {
_rsConfig,
localConfig);
if (!myIndex.isOK()) {
warning() << "Locally stored replica set configuration not valid for current node; "
"waiting for reconfig or remote heartbeat; Got " << myIndex.getStatus() <<
" while validating " << localConfig.toBSON();
myIndex = StatusWith<int>(-1);
if (myIndex.getStatus() == ErrorCodes::NodeNotFound ||
myIndex.getStatus() == ErrorCodes::DuplicateKey) {
warning() << "Locally stored replica set configuration does not have a valid entry "
"for the current node; waiting for reconfig or remote heartbeat; Got \"" <<
myIndex.getStatus() << "\" while validating " << localConfig.toBSON();
myIndex = StatusWith<int>(-1);
}
else {
error() << "Locally stored replica set configuration is invalid; See "
"http://www.mongodb.org/dochub/core/recover-replica-set-from-invalid-config"
" for information on how to recover from this. Got \"" <<
myIndex.getStatus() << "\" while validating " << localConfig.toBSON();
fassertFailedNoTrace(28541);
}
}
if (localConfig.getReplSetName() != _settings.ourSetName()) {