mirror of https://gitee.com/bigwinds/arangodb
Inception should not fatally exit, when in shutdown
This commit is contained in:
parent
511fa4036d
commit
c998e37462
|
@ -101,14 +101,15 @@ void Inception::gossip() {
|
|||
std::make_unique<std::unordered_map<std::string, std::string>>();
|
||||
LOG_TOPIC(DEBUG, Logger::AGENCY) << "Sending gossip message: "
|
||||
<< out->toJson() << " to peer " << clientid;
|
||||
if (cc != nullptr) {
|
||||
if (this->isStopping() || _agent->isStopping() || cc == nullptr) {
|
||||
return;
|
||||
}
|
||||
cc->asyncRequest(
|
||||
clientid, 1, p, rest::RequestType::POST, path,
|
||||
std::make_shared<std::string>(out->toJson()), hf,
|
||||
std::make_shared<GossipCallback>(_agent, version), 1.0, true, 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// pool entries
|
||||
bool complete = true;
|
||||
|
@ -126,14 +127,15 @@ void Inception::gossip() {
|
|||
std::make_unique<std::unordered_map<std::string, std::string>>();
|
||||
LOG_TOPIC(DEBUG, Logger::AGENCY) << "Sending gossip message: "
|
||||
<< out->toJson() << " to pool member " << clientid;
|
||||
if (cc != nullptr) {
|
||||
if (this->isStopping() || _agent->isStopping() || cc == nullptr) {
|
||||
return;
|
||||
}
|
||||
cc->asyncRequest(
|
||||
clientid, 1, pair.second, rest::RequestType::POST, path,
|
||||
std::make_shared<std::string>(out->toJson()), hf,
|
||||
std::make_shared<GossipCallback>(_agent, version), 1.0, true, 0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We're done
|
||||
if (config.poolComplete()) {
|
||||
|
@ -217,7 +219,9 @@ bool Inception::restartingActiveAgent() {
|
|||
std::vector<std::string> informed;
|
||||
|
||||
for (auto& p : gp) {
|
||||
if (cc != nullptr) {
|
||||
if (this->isStopping() && _agent->isStopping() && cc==nullptr) {
|
||||
return false;
|
||||
}
|
||||
auto comres = cc->syncRequest(
|
||||
clientId, 1, p, rest::RequestType::POST, path, greetstr,
|
||||
std::unordered_map<std::string, std::string>(), 2.0);
|
||||
|
@ -231,7 +235,6 @@ bool Inception::restartingActiveAgent() {
|
|||
informed.push_back(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto pool = _agent->config().pool();
|
||||
for (const auto& i : informed) {
|
||||
|
@ -243,7 +246,10 @@ bool Inception::restartingActiveAgent() {
|
|||
|
||||
if (p.first != myConfig.id() && p.first != "") {
|
||||
|
||||
if (cc != nullptr) {
|
||||
if (this->isStopping() || _agent->isStopping() || cc == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto comres = cc->syncRequest(
|
||||
clientId, 1, p.second, rest::RequestType::POST, path, greetstr,
|
||||
std::unordered_map<std::string, std::string>(), 2.0);
|
||||
|
@ -269,6 +275,9 @@ bool Inception::restartingActiveAgent() {
|
|||
|
||||
// Contact leader to update endpoint
|
||||
if (theirLeaderId != theirId) {
|
||||
if (this->isStopping() || _agent->isStopping() || cc==nullptr) {
|
||||
return false;
|
||||
}
|
||||
comres = cc->syncRequest(
|
||||
clientId, 1, theirLeaderEp, rest::RequestType::POST, path,
|
||||
greetstr, std::unordered_map<std::string, std::string>(), 2.0);
|
||||
|
@ -298,6 +307,7 @@ bool Inception::restartingActiveAgent() {
|
|||
|
||||
if (i != active.end()) {
|
||||
if (theirActive != myActive) {
|
||||
if (!this->isStopping()) {
|
||||
LOG_TOPIC(FATAL, Logger::AGENCY)
|
||||
<< "Assumed active RAFT peer and I disagree on active membership:";
|
||||
LOG_TOPIC(FATAL, Logger::AGENCY)
|
||||
|
@ -305,6 +315,7 @@ bool Inception::restartingActiveAgent() {
|
|||
LOG_TOPIC(FATAL, Logger::AGENCY)
|
||||
<< "My active list is " << myActive;
|
||||
FATAL_ERROR_EXIT();
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
*i = "";
|
||||
|
@ -312,14 +323,16 @@ bool Inception::restartingActiveAgent() {
|
|||
}
|
||||
|
||||
} catch (std::exception const& e) {
|
||||
if (!this->isStopping()) {
|
||||
LOG_TOPIC(FATAL, Logger::AGENCY)
|
||||
<< "Assumed active RAFT peer has no active agency list: "
|
||||
<< e.what() << "Administrative intervention needed.";
|
||||
FATAL_ERROR_EXIT();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -395,9 +408,8 @@ void Inception::run() {
|
|||
if (!this->isStopping()) {
|
||||
LOG_TOPIC(FATAL, Logger::AGENCY)
|
||||
<< "Unable to restart with persisted pool. Fatal exit.";
|
||||
}
|
||||
FATAL_ERROR_EXIT();
|
||||
// FATAL ERROR
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -408,10 +420,12 @@ void Inception::run() {
|
|||
// No complete pool after gossip?
|
||||
config = _agent->config();
|
||||
if (!_agent->ready() && !config.poolComplete()) {
|
||||
if (!this->isStopping()) {
|
||||
LOG_TOPIC(FATAL, Logger::AGENCY)
|
||||
<< "Failed to build environment for RAFT algorithm. Bailing out!";
|
||||
FATAL_ERROR_EXIT();
|
||||
}
|
||||
}
|
||||
|
||||
LOG_TOPIC(INFO, Logger::AGENCY) << "Activating agent.";
|
||||
_agent->ready(true);
|
||||
|
|
Loading…
Reference in New Issue