Icinga DB fails after update
Since I have been using Icinga DB (instead of just PostgreSQL) as the backend for my Icinga2 instance, it has happened to me twice that Icinga no longer worked correctly after an update of the Icinga DB package. On closer inspection, it also becomes clear why:
× icingadb.service - Icinga DB
Loaded: loaded (/lib/systemd/system/icingadb.service; enabled; preset: enabled)
Active: failed (Result: exit-code) since Wed 2025-01-22 21:42:50 CET; 27s ago
Duration: 13ms
Main PID: 1853805 (code=exited, status=1/FAILURE)
CPU: 13ms
Jan 22 21:42:50 monitor systemd[1]: Starting icingadb.service - Icinga DB...
Jan 22 21:42:50 monitor systemd[1]: Started icingadb.service - Icinga DB.
Jan 22 21:42:50 monitor icingadb[1853805]: Starting Icinga DB daemon (v1.2.1)
Jan 22 21:42:50 monitor icingadb[1853805]: Connecting to database at 'pgsql://icingadb@localhost:5432/icingadb'
Jan 22 21:42:50 monitor icingadb[1853805]: unexpected database schema version: v3 (expected v4), please make sure you have applied all database migrations after upgrading Icinga DB
Jan 22 21:42:50 monitor systemd[1]: icingadb.service: Main process exited, code=exited, status=1/FAILURE
Jan 22 21:42:50 monitor systemd[1]: icingadb.service: Failed with result 'exit-code'.
Apparently the software was updated with the package update, but the database was left out and not automatically upgraded to the new DB schema. It is unclear to me why this does not happen automatically with an APT update. Fortunately, the problem can be solved quickly by hand:
sudo -u postgres psql icingadb < /usr/share/icingadb/schema/pgsql/upgrades/1.2.1.sql
(If in doubt, select the most recent .sql file in the directory. In my case this was 1.2.1.sql
)_
… and then a
sudo systemctl restart icingadb
afterwards. Icinga should be able to connect to the Icinga DB again.