diff options
author | matt dannenberg <matt.dannenberg@10gen.com> | 2014-11-18 14:33:52 -0500 |
---|---|---|
committer | matt dannenberg <matt.dannenberg@10gen.com> | 2014-11-19 17:09:23 -0500 |
commit | 74cd9523a6b9d81dc60bdf6af05f6fa2e8739159 (patch) | |
tree | 59a1bd40c685ab333640ebf693d7f9d5ce41055e | |
parent | eac11632002de066d03936b5246d1d6162e7d240 (diff) | |
download | mongo-74cd9523a6b9d81dc60bdf6af05f6fa2e8739159.tar.gz |
SERVER-16217 improve replSetReconfig and replSetInitiate error messages
-rw-r--r-- | src/mongo/db/repl/check_quorum_for_config_change.cpp | 32 | ||||
-rw-r--r-- | src/mongo/db/repl/check_quorum_for_config_change.h | 6 | ||||
-rw-r--r-- | src/mongo/db/repl/replset_commands.cpp | 7 |
3 files changed, 32 insertions, 13 deletions
diff --git a/src/mongo/db/repl/check_quorum_for_config_change.cpp b/src/mongo/db/repl/check_quorum_for_config_change.cpp index 2a6804027ae..7064b9a473d 100644 --- a/src/mongo/db/repl/check_quorum_for_config_change.cpp +++ b/src/mongo/db/repl/check_quorum_for_config_change.cpp @@ -122,12 +122,18 @@ namespace repl { _finalStatus = _vetoStatus; return; } - if (_rsConfig->getConfigVersion() == 1 && !_down.empty()) { + if (_rsConfig->getConfigVersion() == 1 && !_badResponses.empty()) { str::stream message; - message << "Could not contact the following nodes during replica set initiation: " << - _down.front().toString(); - for (size_t i = 1; i < _down.size(); ++i) { - message << ", " << _down[i].toString(); + message << "replSetInitiate quorum check failed because not all proposed set members " + "responded affirmatively: "; + for (std::vector<std::pair<HostAndPort, Status> >::const_iterator it = + _badResponses.begin(); + it != _badResponses.end(); + ++it) { + if (it != _badResponses.begin()) { + message << ", "; + } + message << it->first.toString() << " failed with " << it->second.reason(); } _finalStatus = Status(ErrorCodes::NodeNotFound, message); return; @@ -153,6 +159,18 @@ namespace repl { message << ", " << _voters[i].toString(); } } + if (!_badResponses.empty()) { + message << "; the following nodes did not respond affirmatively: "; + for (std::vector<std::pair<HostAndPort, Status> >::const_iterator it = + _badResponses.begin(); + it != _badResponses.end(); + ++it) { + if (it != _badResponses.begin()) { + message << ", "; + } + message << it->first.toString() << " failed with " << it->second.reason(); + } + } _finalStatus = Status(ErrorCodes::NodeNotFound, message); return; } @@ -167,7 +185,7 @@ namespace repl { if (!response.isOK()) { warning() << "Failed to complete heartbeat request to " << request.target << "; " << response.getStatus(); - _down.push_back(request.target); + _badResponses.push_back(std::make_pair(request.target, response.getStatus())); return; } @@ -187,7 +205,7 @@ namespace repl { warning() << "Got error (" << hbStatus << ") response on heartbeat request to " << request.target << "; " << hbResp; - _down.push_back(request.target); + _badResponses.push_back(std::make_pair(request.target, hbStatus)); return; } diff --git a/src/mongo/db/repl/check_quorum_for_config_change.h b/src/mongo/db/repl/check_quorum_for_config_change.h index 04f3f87b340..396ac4dea39 100644 --- a/src/mongo/db/repl/check_quorum_for_config_change.h +++ b/src/mongo/db/repl/check_quorum_for_config_change.h @@ -90,12 +90,12 @@ namespace repl { // Index of the local node's member configuration in _rsConfig. const int _myIndex; - // List of nodes believed to be down. - std::vector<HostAndPort> _down; - // List of voting nodes that have responded affirmatively. std::vector<HostAndPort> _voters; + // List of nodes with bad responses and the bad response status they returned. + std::vector<std::pair<HostAndPort, Status> > _badResponses; + // Total number of responses and timeouts processed. int _numResponses; diff --git a/src/mongo/db/repl/replset_commands.cpp b/src/mongo/db/repl/replset_commands.cpp index 723f6961f45..3b0e10f7f7a 100644 --- a/src/mongo/db/repl/replset_commands.cpp +++ b/src/mongo/db/repl/replset_commands.cpp @@ -567,11 +567,12 @@ namespace { sleepsecs(data["delay"].numberInt()); } + Status status = Status(ErrorCodes::InternalError, "status not set in heartbeat code"); /* we don't call ReplSetCommand::check() here because heartbeat checks many things that are pre-initialization. */ if (!getGlobalReplicationCoordinator()->getSettings().usingReplSets()) { - errmsg = "not running with --replSet"; - return false; + status = Status(ErrorCodes::NoReplicationEnabled, "not running with --replSet"); + return appendCommandStatus(result, status); } /* we want to keep heartbeat connections open when relinquishing primary. @@ -583,7 +584,7 @@ namespace { } ReplSetHeartbeatArgs args; - Status status = args.initialize(cmdObj); + status = args.initialize(cmdObj); if (!status.isOK()) { return appendCommandStatus(result, status); } |