diff --git a/arangod/Agency/AgencyFeature.cpp b/arangod/Agency/AgencyFeature.cpp index a0ab1e2158..7f72f024f2 100644 --- a/arangod/Agency/AgencyFeature.cpp +++ b/arangod/Agency/AgencyFeature.cpp @@ -44,7 +44,7 @@ AgencyFeature::AgencyFeature(application_features::ApplicationServer* server) _notify(false), _supervision(false), _waitForSync(true), - _supervisionFrequency(5.0), + _supervisionFrequency(1.0), _compactionStepSize(1000) { setOptional(true); requiresElevatedPrivileges(false); diff --git a/arangod/Agency/Agent.cpp b/arangod/Agency/Agent.cpp index 99131cde8d..b9064bd649 100644 --- a/arangod/Agency/Agent.cpp +++ b/arangod/Agency/Agent.cpp @@ -381,13 +381,15 @@ void Agent::beginShutdown() { // Personal hygiene Thread::beginShutdown(); + // Stop supervision + if (_config.supervision) { + _supervision.beginShutdown(); + } + // Stop constituent and key value stores _constituent.beginShutdown(); _spearhead.beginShutdown(); _readDB.beginShutdown(); - if (_config.supervision) { - _supervision.beginShutdown(); - } // Wake up all waiting REST handler (waitFor) CONDITION_LOCKER(guard, _appendCV); diff --git a/arangod/Agency/Supervision.cpp b/arangod/Agency/Supervision.cpp index 248731c177..f73131680f 100644 --- a/arangod/Agency/Supervision.cpp +++ b/arangod/Agency/Supervision.cpp @@ -124,7 +124,9 @@ std::vector Supervision::checkDBServers() { report->close(); report->close(); report->close(); - _agent->write(report); + if (!this->isStopping()) { + _agent->write(report); + } } @@ -235,7 +237,7 @@ bool Supervision::start(Agent* agent) { bool Supervision::updateAgencyPrefix (size_t nTries, int intervalSec) { // Try nTries to get agency's prefix in intervals - for (size_t i = 0; i < nTries; i++) { + while (!this->isStopping()) { _snapshot = _agent->readDB().get("/"); if (_snapshot.children().size() > 0) { _agencyPrefix = std::string("/") + _snapshot.children().begin()->first; @@ -256,7 +258,7 @@ void Supervision::getUniqueIds() { uint64_t latestId; // Run forever, supervision does not make sense before the agency data // is initialized by some other server... - while (true) { + while (!this->isStopping()) { try { latestId = std::stoul( _agent->readDB().get(_agencyPrefix + "/Sync/LatestID").slice().toJson());