Hello,
after recklessly running OS update on my Icinga master running on Ubuntu 22.04.03 using “apt upgrade” I realised a minor update for Icinga was released(Releasing Icinga DB 1.2.0 and Icinga DB Web 1.1.2). It includes an update to IcingaDB which requires a schema update to 1.2.0 - I am coming from 1.1.1 .
Sadly the schema update fails: mysql -u root -p icingadb < 1.2.0.sql ERROR 1061 (42000) at line 3: Duplicate key name ‘idx_history_event_time_event_type’
What is causing this issue ? How can it be solved ?
Any hint appreciated - atm my icingadb is down
Thanks in advance.
Kind regards,
Jan
Update: I managed to manually fix this by dropping the index and rerunning the script.
Dunno the impact, but icingadb is running now.
That should be fine. I’m wondering how this happened though. Did you experience performance issues with the history views in Icinga Web before and already added that index earlier yourself? Or did you maybe try to apply the schema upgrade a second time?
Thank you for reporting this issue and we apologize for the
inconvenience. However, this index should not be there if you have not
already performed the schema upgrade [1][2].
Unless you have manually created an index with this exact name, I would
guess that the upgrade script was already executed. Have you interrupted
the schema upgrade before or do you have any automation in place or did,
e.g., a college of yours did an update in parallel?
Edit: The email thingy didn’t liked my message’s format (and hold it in greylisting for quite some time).
@jbrost@apenning Actually I am the only Admin working on the environment. I did not run the script before, at least I do not remember I wasn’t even aware an update was available. I just noticed that IcingaDB printet the warning that my database has schema “4” instead of expected “5”. Then I ran the script which caused the error message. I am sorry I can not tell you how my database got into this state.
Thanks for your post and please excuse the inconvenience.
Your solution of manually dropping the index and re-running the schema upgrade should be totally fine as no change in the schema upgrade alters data.
However, can you please provide information how you got in this situation? This would help us mitigate those issues in the future.
Did you manually ran the schema upgrade twice (maybe interrupting it)?
Which SQL server are you using?
Which OS (or distribution) are you using and how did you install/upgrade Icinga DB? Are you using our packages, those of your distribution or something else?
Hi Alvar,
so i did an “apt-get upgrade” and installed every offered packet. I think there also some packet of an Icinga component available in your mirror.
After i did a reboot, the apache2 won’t start. Because of two mpm workers. I disabled the apache2 modules mpm_prefork and php8.1. I enabled php8.1 again. After this, I am able start Apache2 again.
On the Icingaweb, I saw the error: “It seems that Icinga DB is not running”. So I checked icingadb daemon. It was not running. When I am checkin status, I get this message “unexpected database schema version: v4 (expected v5), please make sure you have applied all database migrations after upgrading Icinga DB”. I did some research and discovered this thread.
Icinga2, version r2.14.2-1, runs on Ubuntu server 22.04.4 LTS. As DB-Server we are using “10.6.16-MariaDB-0ubuntu0.22.04.1”. The complete system was install by a friendly Netways guy with this install-script: https://github.com/NETWAYS/icinga-installer
If you need details, I think you can check ticket [netways #803704].
I am sorry to hear about the issues with the Apache 2. However, those shouldn’t be (directly) related as neither Icinga DB nor Icinga DB Web has a direct Apache 2 dependency.
Regarding the failed schema upgrade: Have you manually executed it twice, canceled it or received some other error? Otherwise I am confused how this index was already there.
The index idx_history_event_time_event_type belongs to the history table, as written on line 3 of the schema upgrade.
The following query, which I just tested on a local testing environment, should do the trick for MySQL/MariaDB:
DROP INDEX idx_history_event_time_event_type ON history;
MariaDB [icingadb]> DROP INDEX idx_history_event_time_event_type ON history;
Query OK, 0 rows affected (0.006 sec)
Records: 0 Duplicates: 0 Warnings: 0
and ran the import again:
root@karlx020:~# mysql -u root icingadb < /usr/share/icingadb/schema/mysql/upgrades/1.2.0.sql
ERROR 1091 (42000) at line 4: Can't DROP INDEX `idx_history_event_time`; check that it exists
root@karlx020:~#
In this case, this is kinda fine as you have already executed the schema upgrade - or at least partially.
Please execute the schema upgrade 1.2.0.sql manually line-by-line in your SQL shell. As you have a partially applied schema upgrade, I am not quite sure in which state your setup currently is.
EDIT:
Yes, as I just wrote. As it seems, the community forum is not the ideal place for (almost) real time communication. (If you’re looking for this, there’s the comfy #Icinga IRC channel on the libera network.)