From cb00a7fd6a8d73fe9ce522eca5e84a039ffa1793 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 13 Oct 2020 13:47:49 +0200 Subject: [PATCH] *DbObject#CalculateConfigHash(): sort groups to be hashed ... to ensure consistent hashes across config reloads. This will likely cause a heavy update once for all objects in >1 group, but it will ensure that this happens the last time. --- lib/db_ido/hostdbobject.cpp | 6 +++++- lib/db_ido/servicedbobject.cpp | 6 +++++- lib/db_ido/userdbobject.cpp | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/db_ido/hostdbobject.cpp b/lib/db_ido/hostdbobject.cpp index 18be0bd52..60d1a99d1 100644 --- a/lib/db_ido/hostdbobject.cpp +++ b/lib/db_ido/hostdbobject.cpp @@ -356,8 +356,12 @@ String HostDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) co Array::Ptr groups = host->GetGroups(); - if (groups) + if (groups) { + groups = groups->ShallowClone(); + ObjectLock oLock (groups); + std::sort(groups->Begin(), groups->End()); hashData += DbObject::HashValue(groups); + } ArrayData parents; diff --git a/lib/db_ido/servicedbobject.cpp b/lib/db_ido/servicedbobject.cpp index ac1f78897..7f711df5e 100644 --- a/lib/db_ido/servicedbobject.cpp +++ b/lib/db_ido/servicedbobject.cpp @@ -308,8 +308,12 @@ String ServiceDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) Array::Ptr groups = service->GetGroups(); - if (groups) + if (groups) { + groups = groups->ShallowClone(); + ObjectLock oLock (groups); + std::sort(groups->Begin(), groups->End()); hashData += DbObject::HashValue(groups); + } ArrayData dependencies; diff --git a/lib/db_ido/userdbobject.cpp b/lib/db_ido/userdbobject.cpp index f0d80b604..439b8fb05 100644 --- a/lib/db_ido/userdbobject.cpp +++ b/lib/db_ido/userdbobject.cpp @@ -150,8 +150,12 @@ String UserDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) co Array::Ptr groups = user->GetGroups(); - if (groups) + if (groups) { + groups = groups->ShallowClone(); + ObjectLock oLock (groups); + std::sort(groups->Begin(), groups->End()); hashData += DbObject::HashValue(groups); + } return SHA256(hashData); }