mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 21:55:03 +02:00
IcingaDB#Stop(): don't block shutdown, timeout instead
This commit is contained in:
parent
f1a942681f
commit
a9c6161def
@ -172,7 +172,9 @@ void IcingaDB::Start(bool runtimeCreated)
|
|||||||
m_Rcon->SuppressQueryKind(Prio::CheckResult);
|
m_Rcon->SuppressQueryKind(Prio::CheckResult);
|
||||||
m_Rcon->SuppressQueryKind(Prio::RuntimeStateSync);
|
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)
|
void IcingaDB::ExceptionHandler(boost::exception_ptr exp)
|
||||||
@ -234,7 +236,11 @@ void IcingaDB::Stop(bool runtimeRemoved)
|
|||||||
Log(LogInformation, "IcingaDB")
|
Log(LogInformation, "IcingaDB")
|
||||||
<< "Flushing history data buffer to Redis.";
|
<< "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")
|
Log(LogInformation, "IcingaDB")
|
||||||
<< "'" << GetName() << "' stopped.";
|
<< "'" << GetName() << "' stopped.";
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
#include "remote/messageorigin.hpp"
|
#include "remote/messageorigin.hpp"
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <future>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <thread>
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ private:
|
|||||||
Timer::Ptr m_StatsTimer;
|
Timer::Ptr m_StatsTimer;
|
||||||
WorkQueue m_WorkQueue{0, 1, LogNotice};
|
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)};
|
Bulker<RedisConnection::Query> m_HistoryBulker {4096, std::chrono::milliseconds(250)};
|
||||||
|
|
||||||
String m_PrefixConfigObject;
|
String m_PrefixConfigObject;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user