Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
1.98k stars 571 forks source link

Update `object#config_hash` after all relations queries #10065

Closed yhabteab closed 1 month ago

yhabteab commented 1 month ago

The IDO is writing the checksums of all Host or/and Service attributes, including group memberships, to the database when the object is first created or, one of its attributes e.g. enable_flapping_detection changes. However, when either the Icinga 2 or the MySQL service is stopped/reloaded unexpectedly right after the IDO has written the checksums to the database but before the remaining queries of the group memberships are executed, the group members will never be written to the database until someone modifies one of the object attributes.

This PR defers the config_hash column update until all object relationships have been updated/inserted.

Master:

This PR:

closes #8813 ref/IP/53530

Al2Klimov commented 1 month ago

I.e., before: SendConfigUpdateHeavy() updates the object itself, calls OnConfigUpdateHeavy(). Have fun with race conditions.

After: SendConfigUpdateHeavy() NULLs config hash, calls OnConfigUpdateHeavy(), updates the object itself.

yhabteab commented 1 month ago

Just added some additional comments!