diff --git a/arangod/MMFiles/MMFilesRestReplicationHandler.cpp b/arangod/MMFiles/MMFilesRestReplicationHandler.cpp index c19d25235d..9a4cffa36b 100644 --- a/arangod/MMFiles/MMFilesRestReplicationHandler.cpp +++ b/arangod/MMFiles/MMFilesRestReplicationHandler.cpp @@ -22,6 +22,7 @@ //////////////////////////////////////////////////////////////////////////////// #include "MMFilesRestReplicationHandler.h" +#include "ApplicationFeatures/ApplicationServer.h" #include "Basics/StaticStrings.h" #include "Basics/VelocyPackHelper.h" #include "Logger/Logger.h" @@ -282,7 +283,7 @@ void MMFilesRestReplicationHandler::handleCommandLoggerFollow() { } // determine start and end tick - MMFilesLogfileManagerState const state = MMFilesLogfileManager::instance()->state(); + MMFilesLogfileManagerState state = MMFilesLogfileManager::instance()->state(); TRI_voc_tick_t tickStart = 0; TRI_voc_tick_t tickEnd = UINT64_MAX; TRI_voc_tick_t firstRegularTick = 0; @@ -416,6 +417,14 @@ void MMFilesRestReplicationHandler::handleCommandLoggerFollow() { } else { resetResponse(rest::ResponseCode::OK); } + + // pull the latest state again, so that the last tick we hand out is always >= + // the last included tick value in the results + while (state.lastCommittedTick < dump._lastFoundTick && + !application_features::ApplicationServer::isStopping()) { + state = MMFilesLogfileManager::instance()->state(); + std::this_thread::sleep_for(std::chrono::microseconds(500)); + } // transfer ownership of the buffer contents _response->setContentType(rest::ContentType::DUMP);