Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HA: Reduce deadlocks via exclusive locking (
SELECT ... FOR UPDATE
)
Within the HA transaction, we always retrieve rows from the `icingadb_instance` table to determine responsibility between the instances. Previously, this selection was performed using a shared lock (`SELECT ... LOCK IN SHARE MODE`). Although selectin rows is generally not an issue, both Icinga DB instances perform an upsert on the same table right after the select statement, resulting in deadlock errors most of the time. In order to reduce the deadlocks on both sides, an exclusive lock on the selected rows is necessary, which can be achieved using the `SELECT ... FOR UDPATE` command. However, deadlocks can still occur if the `icingadb_instance` table is empty, i.e. when rows are available to lock exclusively.
- Loading branch information