mirror of https://github.com/Icinga/icinga2.git
IcingaDB#Stop(): don't block shutdown, timeout instead
This commit is contained in:
parent
3a8efcb4ea
commit
6b5106ffdd
|
@ -172,7 +172,9 @@ void IcingaDB::Start(bool runtimeCreated)
|
|||
m_Rcon->SuppressQueryKind(Prio::CheckResult);
|
||||
m_Rcon->SuppressQueryKind(Prio::RuntimeStateSync);
|
||||
|
||||
m_HistoryThread = std::thread([this]() { ForwardHistoryEntries(); });
|
||||
Ptr keepAlive (this);
|
||||
|
||||
m_HistoryThread = std::async(std::launch::async, [this, keepAlive]() { ForwardHistoryEntries(); });
|
||||
}
|
||||
|
||||
void IcingaDB::ExceptionHandler(boost::exception_ptr exp)
|
||||
|
@ -234,7 +236,11 @@ void IcingaDB::Stop(bool runtimeRemoved)
|
|||
Log(LogInformation, "IcingaDB")
|
||||
<< "Flushing history data buffer to Redis.";
|
||||
|
||||
m_HistoryThread.join();
|
||||
if (m_HistoryThread.wait_for(std::chrono::minutes(1)) == std::future_status::timeout) {
|
||||
Log(LogCritical, "IcingaDB")
|
||||
<< "Flushing takes more than one minute (while we're about to shut down). Giving up and discarding "
|
||||
<< m_HistoryBulker.Size() << " queued history queries.";
|
||||
}
|
||||
|
||||
Log(LogInformation, "IcingaDB")
|
||||
<< "'" << GetName() << "' stopped.";
|
||||
|
|
|
@ -15,10 +15,10 @@
|
|||
#include "remote/messageorigin.hpp"
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <future>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
|
@ -182,7 +182,7 @@ private:
|
|||
Timer::Ptr m_StatsTimer;
|
||||
WorkQueue m_WorkQueue{0, 1, LogNotice};
|
||||
|
||||
std::thread m_HistoryThread;
|
||||
std::future<void> m_HistoryThread;
|
||||
Bulker<RedisConnection::Query> m_HistoryBulker {4096, std::chrono::milliseconds(250)};
|
||||
|
||||
String m_PrefixConfigObject;
|
||||
|
|
Loading…
Reference in New Issue