diff --git a/arangod/Agency/AgencyComm.cpp b/arangod/Agency/AgencyComm.cpp index 3be2575c17..7650dec527 100644 --- a/arangod/Agency/AgencyComm.cpp +++ b/arangod/Agency/AgencyComm.cpp @@ -445,11 +445,8 @@ std::unique_ptr AgencyCommManager::acquire( } else { if(endpoint.empty()) { endpoint = _endpoints.front(); - LOG_TOPIC(INFO, Logger::AGENCYCOMM) << "Using endpoint " << endpoint + LOG_TOPIC(DEBUG, Logger::AGENCYCOMM) << "Using endpoint " << endpoint << " for agency communication, full selection:"; - for (auto const& e : _endpoints) { - LOG_TOPIC(INFO, Logger::AGENCYCOMM) << "endpoint: " << e; - } } if (!_unusedConnections[endpoint].empty()) { connection.reset(_unusedConnections[endpoint].back().release()); @@ -1219,14 +1216,31 @@ AgencyCommResult AgencyComm::sendWithFailover( std::chrono::duration(timeout); double conTimeout = 1.0; - for (uint64_t tries = 0; tries < MAX_TRIES; ++tries) { + int tries = 0; + while (true) { // will be left by timeout eventually // Raise waits to a maximum 10 seconds auto waitUntil = std::chrono::steady_clock::now() + waitInterval; - if (waitInterval.count() < 5.0) { - waitInterval *= 2; + + // timeout exit startegy + if (std::chrono::steady_clock::now() < timeOut) { + if (tries > 0) { + std::this_thread::sleep_for(waitUntil-std::chrono::steady_clock::now()); + if (waitInterval.count() < 5.0) { + waitInterval *= 2; + } + } + } else { + LOG_TOPIC(DEBUG, Logger::AGENCYCOMM) + << "Unsuccessful AgencyComm: Timeout" + << "errorCode: " << result.errorCode() + << " errorMessage: " << result.errorMessage() + << " errorDetails: " << result.errorDetails(); + return result; } + ++tries; + if (connection == nullptr) { AgencyCommResult result(400, "No endpoints for agency found."); LOG_TOPIC(ERR, Logger::AGENCYCOMM) << result._message; @@ -1285,19 +1299,6 @@ AgencyCommResult AgencyComm::sendWithFailover( AgencyCommManager::MANAGER->failed(std::move(connection), endpoint); endpoint.clear(); connection = AgencyCommManager::MANAGER->acquire(endpoint); - - // timeout exit startegy - if (std::chrono::steady_clock::now() < timeOut) { - std::this_thread::sleep_for(waitUntil-std::chrono::steady_clock::now()); - } else { - LOG_TOPIC(DEBUG, Logger::AGENCYCOMM) - << "Unsuccessful AgencyComm: Timeout" - << "errorCode: " << result.errorCode() - << " errorMessage: " << result.errorMessage() - << " errorDetails: " << result.errorDetails(); - return result; - } - } // other error diff --git a/arangod/Agency/AgencyComm.h b/arangod/Agency/AgencyComm.h index d312f79e7a..e0c49c1152 100644 --- a/arangod/Agency/AgencyComm.h +++ b/arangod/Agency/AgencyComm.h @@ -475,7 +475,6 @@ class AgencyComm { static std::string const AGENCY_URL_PREFIX; static uint64_t const INITIAL_SLEEP_TIME = 5000; static uint64_t const MAX_SLEEP_TIME = 50000; - static uint64_t const MAX_TRIES = 3; public: AgencyCommResult sendServerState(double ttl);