IcingaDB: Always send dependencies state HSET updates to Redis

This commit is contained in:
Yonas Habteab 2025-02-17 17:47:17 +01:00
parent 21cd5e00fa
commit da637c3741

View File

@ -1386,6 +1386,7 @@ void IcingaDB::UpdateDependenciesState(const Checkable::Ptr& checkable, const De
streamStates.emplace_back(std::move(xAdd)); streamStates.emplace_back(std::move(xAdd));
}); });
std::map<String, RedisConnection::Query> hMSets;
for (auto& dependencyGroup : dependencyGroups) { for (auto& dependencyGroup : dependencyGroups) {
bool isRedundancyGroup(dependencyGroup->IsRedundancyGroup()); bool isRedundancyGroup(dependencyGroup->IsRedundancyGroup());
if (isRedundancyGroup && dependencyGroup->GetIcingaDBIdentifier().IsEmpty()) { 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); addDependencyStateToStream(m_PrefixConfigObject + "dependency:edge:state", stateAttrs);
AddDataToHmSets(hMSets, RedisKey::DependencyEdgeState, stateAttrs->Get("id"), stateAttrs);
} }
if (isRedundancyGroup) { if (isRedundancyGroup) {
@ -1425,10 +1427,19 @@ void IcingaDB::UpdateDependenciesState(const Checkable::Ptr& checkable, const De
addDependencyStateToStream(m_PrefixConfigObject + "redundancygroup:state", stateAttrs); addDependencyStateToStream(m_PrefixConfigObject + "redundancygroup:state", stateAttrs);
addDependencyStateToStream(m_PrefixConfigObject + "dependency:edge:state", sharedGroupState); addDependencyStateToStream(m_PrefixConfigObject + "dependency:edge:state", sharedGroupState);
AddDataToHmSets(hMSets, RedisKey::RedundancyGroupState, dependencyGroup->GetIcingaDBIdentifier(), stateAttrs);
AddDataToHmSets(hMSets, RedisKey::DependencyEdgeState, dependencyGroup->GetIcingaDBIdentifier(), sharedGroupState);
} }
} }
if (!streamStates.empty()) { 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}); m_Rcon->FireAndForgetQueries(std::move(streamStates), Prio::RuntimeStateStream, {0, 1});
} }
} }