When UPSERT and DELETE statements are executed at the same time, a
deadlock can occur if both want to get an exclusive lock on one of the
PRIMARY KEY index pages. This happens with DELETE statements when there
is no suitable index for the columns used in the WHERE clause, which is
true for our history retention queries since commit eccac78. This PR
fixes the problem by adding a suitable index for the columns used in
these queries.
At the moment Icinga DB Web doesn't know the column types, so it sends
SQL queries with LIKE operators for all suggestions in the search bar,
which fails for numeric and enum types on PostgreSQL. To support this,
the LIKE operator (internally translated to ~~) is overloaded. Note
that this is only a temporary solution until Icinga DB Web provides
column type support.
Before:
idb=# select * from icingadb_instance where responsible = 'y';
ERROR: operator does not exist: boolenum = unknown
LINE 1: select * from icingadb_instance where responsible = 'y';
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
idb=#
refs #136