mirror of https://github.com/Icinga/icinga2.git
IcingaDB: start initial sync after all child connections are established
Icinga started the initial config sync right after the first Redis connection was established. If any other connections would take longer to connect than when it's first needed, queries were discarded.
This commit is contained in:
parent
a50120c399
commit
929ebd0f6c
|
@ -73,22 +73,31 @@ void IcingaDB::Start(bool runtimeCreated)
|
|||
if (!ctype)
|
||||
continue;
|
||||
|
||||
m_Rcons[ctype] = new RedisConnection(GetHost(), GetPort(), GetPath(), GetPassword(), GetDbIndex(),
|
||||
RedisConnection::Ptr con = new RedisConnection(GetHost(), GetPort(), GetPath(), GetPassword(), GetDbIndex(),
|
||||
GetEnableTls(), GetInsecureNoverify(), GetCertPath(), GetKeyPath(), GetCaPath(), GetCrlPath(),
|
||||
GetTlsProtocolmin(), GetCipherList(), GetConnectTimeout(), GetDebugInfo(), m_Rcon);
|
||||
|
||||
con->SetConnectedCallback([this, con](boost::asio::yield_context& yc) {
|
||||
con->SetConnectedCallback(nullptr);
|
||||
|
||||
size_t pending = --m_PendingRcons;
|
||||
Log(LogDebug, "IcingaDB") << pending << " pending child connections remaining";
|
||||
if (pending == 0) {
|
||||
m_WorkQueue.Enqueue([this]() { OnConnectedHandler(); });
|
||||
}
|
||||
});
|
||||
|
||||
m_Rcons[ctype] = std::move(con);
|
||||
}
|
||||
|
||||
auto connectedCallback ([this](boost::asio::yield_context& yc) {
|
||||
m_WorkQueue.Enqueue([this]() { OnConnectedHandler(); });
|
||||
});
|
||||
m_PendingRcons = m_Rcons.size();
|
||||
|
||||
m_Rcon->SetConnectedCallback([this](boost::asio::yield_context& yc) {
|
||||
m_Rcon->SetConnectedCallback(nullptr);
|
||||
|
||||
m_Rcon->SetConnectedCallback([this, connectedCallback](boost::asio::yield_context& yc) {
|
||||
for (auto& kv : m_Rcons) {
|
||||
kv.second->Start();
|
||||
}
|
||||
|
||||
m_Rcon->SetConnectedCallback(connectedCallback);
|
||||
connectedCallback(yc);
|
||||
});
|
||||
m_Rcon->Start();
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "icinga/downtime.hpp"
|
||||
#include "remote/messageorigin.hpp"
|
||||
#include <boost/thread/once.hpp>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
@ -169,6 +170,7 @@ private:
|
|||
|
||||
RedisConnection::Ptr m_Rcon;
|
||||
std::unordered_map<ConfigType*, RedisConnection::Ptr> m_Rcons;
|
||||
std::atomic_size_t m_PendingRcons;
|
||||
|
||||
struct {
|
||||
DumpedGlobals CustomVar, ActionUrl, NotesUrl, IconImage;
|
||||
|
|
Loading…
Reference in New Issue