From da637c3741b0482de241b66908b7a4a8ce57d345 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Mon, 17 Feb 2025 17:47:17 +0100 Subject: [PATCH] IcingaDB: Always send dependencies state HSET updates to Redis --- lib/icingadb/icingadb-objects.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/icingadb/icingadb-objects.cpp b/lib/icingadb/icingadb-objects.cpp index 283770490..04043db53 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -1386,6 +1386,7 @@ void IcingaDB::UpdateDependenciesState(const Checkable::Ptr& checkable, const De streamStates.emplace_back(std::move(xAdd)); }); + std::map hMSets; for (auto& dependencyGroup : dependencyGroups) { bool isRedundancyGroup(dependencyGroup->IsRedundancyGroup()); if (isRedundancyGroup && dependencyGroup->GetIcingaDBIdentifier().IsEmpty()) { @@ -1413,6 +1414,7 @@ void IcingaDB::UpdateDependenciesState(const Checkable::Ptr& checkable, const De } addDependencyStateToStream(m_PrefixConfigObject + "dependency:edge:state", stateAttrs); + AddDataToHmSets(hMSets, RedisKey::DependencyEdgeState, stateAttrs->Get("id"), stateAttrs); } if (isRedundancyGroup) { @@ -1425,10 +1427,19 @@ void IcingaDB::UpdateDependenciesState(const Checkable::Ptr& checkable, const De addDependencyStateToStream(m_PrefixConfigObject + "redundancygroup:state", stateAttrs); addDependencyStateToStream(m_PrefixConfigObject + "dependency:edge:state", sharedGroupState); + AddDataToHmSets(hMSets, RedisKey::RedundancyGroupState, dependencyGroup->GetIcingaDBIdentifier(), stateAttrs); + AddDataToHmSets(hMSets, RedisKey::DependencyEdgeState, dependencyGroup->GetIcingaDBIdentifier(), sharedGroupState); } } if (!streamStates.empty()) { + RedisConnection::Queries queries; + for (auto& [redisKey, query] : hMSets) { + query.insert(query.begin(), {"HSET", redisKey}); + queries.emplace_back(std::move(query)); + } + + m_Rcon->FireAndForgetQueries(std::move(queries), Prio::RuntimeStateSync); m_Rcon->FireAndForgetQueries(std::move(streamStates), Prio::RuntimeStateStream, {0, 1}); } }