From a9bb11b16d4b3939cf18534b3bf32c2dff230ab5 Mon Sep 17 00:00:00 2001 From: Yonas Habteab Date: Fri, 14 Feb 2025 16:53:47 +0100 Subject: [PATCH] (Un)register dependencies from parent prior to child Checkable --- lib/icinga/dependency.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/icinga/dependency.cpp b/lib/icinga/dependency.cpp index c45015e8f..52456ff4b 100644 --- a/lib/icinga/dependency.cpp +++ b/lib/icinga/dependency.cpp @@ -251,16 +251,24 @@ void Dependency::OnAllConfigLoaded() // InitChildParentReferences() has to be called before. VERIFY(m_Child && m_Parent); - m_Child->AddDependency(this); + // Icinga DB will implicitly send config updates for the parent Checkable to refresh its affects_children and + // affected_children columns when registering the dependency from the child Checkable. So, we need to register + // the dependency from the parent Checkable first, otherwise the config update of the parent Checkable will change + // nothing at all. m_Parent->AddReverseDependency(this); + m_Child->AddDependency(this); } void Dependency::Stop(bool runtimeRemoved) { ObjectImpl::Stop(runtimeRemoved); - GetChild()->RemoveDependency(this, runtimeRemoved); + // Icinga DB will implicitly send config updates for the parent Checkable to refresh its affects_children and + // affected_children columns when removing the dependency from the child Checkable. So, we need to remove the + // dependency from the parent Checkable first, otherwise the config update of the parent Checkable will change + // nothing at all. GetParent()->RemoveReverseDependency(this); + GetChild()->RemoveDependency(this, runtimeRemoved); } bool Dependency::IsAvailable(DependencyType dt) const