From 30be02bcae01546ac20c52f489bef6bc531ecfa5 Mon Sep 17 00:00:00 2001 From: Jean Flach Date: Wed, 9 Aug 2017 17:41:43 +0200 Subject: [PATCH 1/7] Alter DowntimeRemoval behaviour This adds an additional index to the downtimehistory and updates the dbevents in a way that it uses that index --- lib/db_ido/dbconnection.hpp | 2 +- lib/db_ido/dbevents.cpp | 1 + lib/db_ido_mysql/schema/mysql.sql | 11 ++++++++--- lib/db_ido_mysql/schema/upgrade/2.8.0.sql | 22 ++++++++++++++++++++++ lib/db_ido_pgsql/schema/pgsql.sql | 8 ++++++-- lib/db_ido_pgsql/schema/upgrade/2.8.0.sql | 21 +++++++++++++++++++++ 6 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 lib/db_ido_mysql/schema/upgrade/2.8.0.sql create mode 100644 lib/db_ido_pgsql/schema/upgrade/2.8.0.sql diff --git a/lib/db_ido/dbconnection.hpp b/lib/db_ido/dbconnection.hpp index dc677d075..f26735f3a 100644 --- a/lib/db_ido/dbconnection.hpp +++ b/lib/db_ido/dbconnection.hpp @@ -29,7 +29,7 @@ #include #include -#define IDO_CURRENT_SCHEMA_VERSION "1.14.2" +#define IDO_CURRENT_SCHEMA_VERSION "1.14.3" #define IDO_COMPAT_SCHEMA_VERSION "1.14.2" namespace icinga diff --git a/lib/db_ido/dbevents.cpp b/lib/db_ido/dbevents.cpp index 706e3ddd3..557a0e65d 100644 --- a/lib/db_ido/dbevents.cpp +++ b/lib/db_ido/dbevents.cpp @@ -586,6 +586,7 @@ void DbEvents::RemoveDowntimeInternal(std::vector& queries, const Downt query1.Type = DbQueryDelete; query1.Category = DbCatDowntime; query1.WhereCriteria = new Dictionary(); + query1.WhereCriteria->Set("object_id", checkable); query1.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(downtime->GetEntryTime())); query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */ diff --git a/lib/db_ido_mysql/schema/mysql.sql b/lib/db_ido_mysql/schema/mysql.sql index 77f022b05..8f7238a97 100644 --- a/lib/db_ido_mysql/schema/mysql.sql +++ b/lib/db_ido_mysql/schema/mysql.sql @@ -2,7 +2,7 @@ -- mysql.sql -- DB definition for IDO MySQL -- --- Copyright (c) 2009-2016 Icinga Development Team (https://www.icinga.com/) +-- Copyright (c) 2009-2017 Icinga Development Team (https://www.icinga.com/) -- -- -- -------------------------------------------------------- @@ -1681,10 +1681,15 @@ CREATE INDEX idx_hostdependencies_dependent_host_object_id on icinga_hostdepende CREATE INDEX idx_service_contacts_service_id on icinga_service_contacts(service_id); CREATE INDEX idx_host_contacts_host_id on icinga_host_contacts(host_id); +-- #5458 +CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time); +CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time); + + -- ----------------------------------------- -- set dbversion -- ----------------------------------------- -INSERT INTO icinga_dbversion (name, version, create_time, modify_time) VALUES ('idoutils', '1.14.2', NOW(), NOW()) -ON DUPLICATE KEY UPDATE version='1.14.2', modify_time=NOW(); +INSERT INTO icinga_dbversion (name, version, create_time, modify_time) VALUES ('idoutils', '1.14.3', NOW(), NOW()) +ON DUPLICATE KEY UPDATE version='1.14.3', modify_time=NOW(); diff --git a/lib/db_ido_mysql/schema/upgrade/2.8.0.sql b/lib/db_ido_mysql/schema/upgrade/2.8.0.sql new file mode 100644 index 000000000..5e0facf9f --- /dev/null +++ b/lib/db_ido_mysql/schema/upgrade/2.8.0.sql @@ -0,0 +1,22 @@ +-- ----------------------------------------- +-- upgrade path for Icinga 2.8.0 +-- +-- ----------------------------------------- +-- Copyright (c) 2017 Icinga Development Team (https://www.icinga.com) +-- +-- Please check https://docs.icinga.com for upgrading information! +-- ----------------------------------------- + +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; + +-- ----------------------------------------- +-- #5458 IDO: Improve downtime removal/cancel +-- ----------------------------------------- + +CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time); +CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time); + +-- ----------------------------------------- +-- set dbversion +-- ----------------------------------------- +INSERT INTO icinga_dbversion (name, version, create_time, modify_time) VALUES ('idoutils', '1.14.3', NOW(), NOW()) ON DUPLICATE KEY UPDATE version='1.14.3', modify_time=NOW(); diff --git a/lib/db_ido_pgsql/schema/pgsql.sql b/lib/db_ido_pgsql/schema/pgsql.sql index fda5ea591..bbd54b4be 100644 --- a/lib/db_ido_pgsql/schema/pgsql.sql +++ b/lib/db_ido_pgsql/schema/pgsql.sql @@ -2,7 +2,7 @@ -- pgsql.sql -- DB definition for IDO Postgresql -- --- Copyright (c) 2009-2016 Icinga Development Team (https://www.icinga.com/) +-- Copyright (c) 2009-2017 Icinga Development Team (https://www.icinga.com/) -- -- -------------------------------------------------------- @@ -1721,9 +1721,13 @@ CREATE INDEX idx_hostdependencies_dependent_host_object_id on icinga_hostdepende CREATE INDEX idx_service_contacts_service_id on icinga_service_contacts(service_id); CREATE INDEX idx_host_contacts_host_id on icinga_host_contacts(host_id); +-- #5458 +CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time); +CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time); + -- ----------------------------------------- -- set dbversion -- ----------------------------------------- -SELECT updatedbversion('1.14.2'); +SELECT updatedbversion('1.14.3'); diff --git a/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql b/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql new file mode 100644 index 000000000..620486748 --- /dev/null +++ b/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql @@ -0,0 +1,21 @@ +-- ----------------------------------------- +-- upgrade path for Icinga 2.8.0 +-- +-- ----------------------------------------- +-- Copyright (c) 2017 Icinga Development Team (https://www.icinga.com) +-- +-- Please check https://docs.icinga.com for upgrading information! +-- ----------------------------------------- + +-- ----------------------------------------- +-- #5458 IDO: Improve downtime removal/cancel +-- ----------------------------------------- + +CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time); +CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time); + +-- ----------------------------------------- +-- set dbversion +-- ----------------------------------------- + +SELECT updatedbversion('1.14.3'); From 1632415370643c4279b6adc4ce1e144b20b86059 Mon Sep 17 00:00:00 2001 From: Jean Flach Date: Thu, 10 Aug 2017 16:42:02 +0200 Subject: [PATCH 2/7] Fix commenthistory refs #5492 --- lib/db_ido/dbevents.cpp | 4 ++-- lib/db_ido_mysql/schema/mysql.sql | 7 +++++-- lib/db_ido_mysql/schema/upgrade/2.8.0.sql | 7 +++++++ lib/db_ido_pgsql/schema/pgsql.sql | 4 ++++ lib/db_ido_pgsql/schema/upgrade/2.8.0.sql | 6 ++++++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/db_ido/dbevents.cpp b/lib/db_ido/dbevents.cpp index 557a0e65d..315bd5384 100644 --- a/lib/db_ido/dbevents.cpp +++ b/lib/db_ido/dbevents.cpp @@ -409,7 +409,7 @@ void DbEvents::RemoveCommentInternal(std::vector& queries, const Commen query1.Category = DbCatComment; query1.WhereCriteria = new Dictionary(); query1.WhereCriteria->Set("object_id", checkable); - query1.WhereCriteria->Set("comment_time", DbValue::FromTimestamp(entry_time)); + query1.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(entry_time)); query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */ query1.WhereCriteria->Set("name", comment->GetName()); queries.push_back(query1); @@ -430,7 +430,7 @@ void DbEvents::RemoveCommentInternal(std::vector& queries, const Commen query2.WhereCriteria = new Dictionary(); query2.WhereCriteria->Set("object_id", checkable); - query2.WhereCriteria->Set("comment_time", DbValue::FromTimestamp(entry_time)); + query2.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(entry_time)); query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */ query2.WhereCriteria->Set("name", comment->GetName()); queries.push_back(query2); diff --git a/lib/db_ido_mysql/schema/mysql.sql b/lib/db_ido_mysql/schema/mysql.sql index 8f7238a97..2acff559a 100644 --- a/lib/db_ido_mysql/schema/mysql.sql +++ b/lib/db_ido_mysql/schema/mysql.sql @@ -1682,9 +1682,12 @@ CREATE INDEX idx_service_contacts_service_id on icinga_service_contacts(service_ CREATE INDEX idx_host_contacts_host_id on icinga_host_contacts(host_id); -- #5458 -CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time); -CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time); +create index idx_downtimehistory_remove on icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time); +create index idx_scheduleddowntime_remove on icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time); +-- #5492 +CREATE INDEX idx_commenthistory_remove ON icinga_commenthistory (object_id, entry_time); +CREATE INDEX idx_comments_remove ON icinga_comments (object_id, entry_time); -- ----------------------------------------- -- set dbversion diff --git a/lib/db_ido_mysql/schema/upgrade/2.8.0.sql b/lib/db_ido_mysql/schema/upgrade/2.8.0.sql index 5e0facf9f..5fed98312 100644 --- a/lib/db_ido_mysql/schema/upgrade/2.8.0.sql +++ b/lib/db_ido_mysql/schema/upgrade/2.8.0.sql @@ -16,6 +16,13 @@ SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time); CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time); +-- ----------------------------------------- +-- #5492 IDO: Improve comment removal +-- ----------------------------------------- + +CREATE INDEX idx_commenthistory_remove ON icinga_commenthistory (object_id, entry_time); +CREATE INDEX idx_comments_remove ON icinga_comments (object_id, entry_time); + -- ----------------------------------------- -- set dbversion -- ----------------------------------------- diff --git a/lib/db_ido_pgsql/schema/pgsql.sql b/lib/db_ido_pgsql/schema/pgsql.sql index bbd54b4be..fb033d2b7 100644 --- a/lib/db_ido_pgsql/schema/pgsql.sql +++ b/lib/db_ido_pgsql/schema/pgsql.sql @@ -1725,6 +1725,10 @@ CREATE INDEX idx_host_contacts_host_id on icinga_host_contacts(host_id); CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time); CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time); +-- #5492 +CREATE INDEX idx_commenthistory_remove ON icinga_commenthistory (object_id, entry_time); +CREATE INDEX idx_comments_remove ON icinga_comments (object_id, entry_time); + -- ----------------------------------------- -- set dbversion -- ----------------------------------------- diff --git a/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql b/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql index 620486748..8e49f17eb 100644 --- a/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql +++ b/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql @@ -14,6 +14,12 @@ CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time); CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time); +-- ----------------------------------------- +-- #5492 +-- ----------------------------------------- + +CREATE INDEX idx_commenthistory_remove ON icinga_commenthistory (object_id, entry_time); +CREATE INDEX idx_comments_remove ON icinga_comments (object_id, entry_time); -- ----------------------------------------- -- set dbversion -- ----------------------------------------- From 6f6703042e1db672b30fd2f4da4235f6605a9c2e Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 26 Oct 2017 13:59:37 +0200 Subject: [PATCH 3/7] ido: Drop unused instance_id indices from comments, downtimes and their related history tables --- lib/db_ido_mysql/schema/upgrade/2.8.0.sql | 52 +++++++++++++++++++++++ lib/db_ido_pgsql/schema/upgrade/2.8.0.sql | 5 +++ 2 files changed, 57 insertions(+) diff --git a/lib/db_ido_mysql/schema/upgrade/2.8.0.sql b/lib/db_ido_mysql/schema/upgrade/2.8.0.sql index 5fed98312..db546d007 100644 --- a/lib/db_ido_mysql/schema/upgrade/2.8.0.sql +++ b/lib/db_ido_mysql/schema/upgrade/2.8.0.sql @@ -9,6 +9,58 @@ SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; +-- -------------------------------------------------------- +-- Helper functions and procedures for DROP INDEX IF EXISTS +-- -------------------------------------------------------- + +DELIMITER // +DROP FUNCTION IF EXISTS ido_index_exists // +CREATE FUNCTION ido_index_exists( + f_table_name varchar(64), + f_index_name varchar(64) +) + RETURNS BOOL + DETERMINISTIC + READS SQL DATA + BEGIN + DECLARE index_exists BOOL DEFAULT FALSE; + SELECT EXISTS ( + SELECT 1 + FROM information_schema.statistics + WHERE table_schema = SCHEMA() + AND table_name = f_table_name + AND index_name = f_index_name + ) INTO index_exists; + RETURN index_exists; + END // + +DROP PROCEDURE IF EXISTS ido_drop_index_if_exists // +CREATE PROCEDURE ido_drop_index_if_exists ( + IN p_table_name varchar(64), + IN p_index_name varchar(64) +) + DETERMINISTIC + MODIFIES SQL DATA + BEGIN + IF ido_index_exists(p_table_name, p_index_name) + THEN + SET @ido_drop_index_sql = CONCAT('ALTER TABLE `', SCHEMA(), '`.`', p_table_name, '` DROP INDEX `', p_index_name, '`'); + PREPARE stmt FROM @ido_drop_index_sql; + EXECUTE stmt; + DEALLOCATE PREPARE stmt; + SET @ido_drop_index_sql = NULL; + END IF; + END // +DELIMITER ; + +CALL ido_drop_index_if_exists('icinga_downtimehistory', 'instance_id'); +CALL ido_drop_index_if_exists('icinga_scheduleddowntime', 'instance_id'); +CALL ido_drop_index_if_exists('icinga_commenthistory', 'instance_id'); +CALL ido_drop_index_if_exists('icinga_comments', 'instance_id'); + +DROP FUNCTION ido_index_exists; +DROP PROCEDURE ido_drop_index_if_exists; + -- ----------------------------------------- -- #5458 IDO: Improve downtime removal/cancel -- ----------------------------------------- diff --git a/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql b/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql index 8e49f17eb..cae9b6699 100644 --- a/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql +++ b/lib/db_ido_pgsql/schema/upgrade/2.8.0.sql @@ -7,6 +7,11 @@ -- Please check https://docs.icinga.com for upgrading information! -- ----------------------------------------- +ALTER TABLE icinga_downtimehistory DROP CONSTRAINT IF EXISTS UQ_downtimehistory; +ALTER TABLE icinga_scheduleddowntime DROP CONSTRAINT IF EXISTS UQ_scheduleddowntime; +ALTER TABLE icinga_commenthistory DROP CONSTRAINT IF EXISTS UQ_commenthistory; +ALTER TABLE icinga_comments DROP CONSTRAINT IF EXISTS UQ_comments; + -- ----------------------------------------- -- #5458 IDO: Improve downtime removal/cancel -- ----------------------------------------- From e83ddbd8b224bd40f5bd8a9838ccaf3faee0e42a Mon Sep 17 00:00:00 2001 From: Jean Flach Date: Mon, 6 Nov 2017 10:59:44 +0100 Subject: [PATCH 4/7] Remove unnecessary keys from where clauses --- lib/db_ido/dbevents.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/db_ido/dbevents.cpp b/lib/db_ido/dbevents.cpp index 315bd5384..0b2c75430 100644 --- a/lib/db_ido/dbevents.cpp +++ b/lib/db_ido/dbevents.cpp @@ -375,10 +375,8 @@ void DbEvents::AddCommentInternal(std::vector& queries, const Comment:: query1.WhereCriteria = new Dictionary(); query1.WhereCriteria->Set("object_id", checkable); + query1.WhereCriteria->Set("name", comment->GetName()); query1.WhereCriteria->Set("comment_time", DbValue::FromTimestamp(entry_time)); - query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */ - /* Match the unique constraint. */ - query1.WhereCriteria->Set("internal_comment_id", comment->GetLegacyId()); } else { query1.Table = "commenthistory"; query1.Type = DbQueryInsert; @@ -410,7 +408,6 @@ void DbEvents::RemoveCommentInternal(std::vector& queries, const Commen query1.WhereCriteria = new Dictionary(); query1.WhereCriteria->Set("object_id", checkable); query1.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(entry_time)); - query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */ query1.WhereCriteria->Set("name", comment->GetName()); queries.push_back(query1); @@ -431,7 +428,6 @@ void DbEvents::RemoveCommentInternal(std::vector& queries, const Commen query2.WhereCriteria = new Dictionary(); query2.WhereCriteria->Set("object_id", checkable); query2.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(entry_time)); - query2.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */ query2.WhereCriteria->Set("name", comment->GetName()); queries.push_back(query2); } @@ -521,10 +517,8 @@ void DbEvents::AddDowntimeInternal(std::vector& queries, const Downtime query1.WhereCriteria = new Dictionary(); query1.WhereCriteria->Set("object_id", checkable); + query1.WhereCriteria->Set("name", downtime->GetName()); query1.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(downtime->GetEntryTime())); - query1.WhereCriteria->Set("instance_id", 0); /* DbConnection class fills in real ID */ - /* Match the unique constraint. */ - query1.WhereCriteria->Set("internal_downtime_id", downtime->GetLegacyId()); } else { query1.Table = "downtimehistory"; query1.Type = DbQueryInsert; From e0e7f9ae6b7335e0c500ce9a5110f552605a7b4e Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 7 Nov 2017 16:18:06 +0100 Subject: [PATCH 5/7] DB IDO: Force users to upgrade the schema to avoid workaround fixes/missing indexes --- lib/db_ido/dbconnection.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/db_ido/dbconnection.hpp b/lib/db_ido/dbconnection.hpp index f26735f3a..2b1d77d6e 100644 --- a/lib/db_ido/dbconnection.hpp +++ b/lib/db_ido/dbconnection.hpp @@ -30,7 +30,7 @@ #include #define IDO_CURRENT_SCHEMA_VERSION "1.14.3" -#define IDO_COMPAT_SCHEMA_VERSION "1.14.2" +#define IDO_COMPAT_SCHEMA_VERSION "1.14.3" namespace icinga { From 42b1e7ce79ac8ebbfd4f1207bf1c957ca40eae1c Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 7 Nov 2017 16:32:50 +0100 Subject: [PATCH 6/7] Use the entry_time for icinga_comments updates This follows all other queries in their where condition using entry_time for comments/downtimes. --- lib/db_ido/dbevents.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/db_ido/dbevents.cpp b/lib/db_ido/dbevents.cpp index 0b2c75430..2d6653579 100644 --- a/lib/db_ido/dbevents.cpp +++ b/lib/db_ido/dbevents.cpp @@ -376,7 +376,7 @@ void DbEvents::AddCommentInternal(std::vector& queries, const Comment:: query1.WhereCriteria = new Dictionary(); query1.WhereCriteria->Set("object_id", checkable); query1.WhereCriteria->Set("name", comment->GetName()); - query1.WhereCriteria->Set("comment_time", DbValue::FromTimestamp(entry_time)); + query1.WhereCriteria->Set("entry_time", DbValue::FromTimestamp(entry_time)); } else { query1.Table = "commenthistory"; query1.Type = DbQueryInsert; From a1afb524646fa36ed68b2d679851e5888f94c5e6 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 7 Nov 2017 17:03:11 +0100 Subject: [PATCH 7/7] Update upgrading docs for DB IDO schema update --- doc/16-upgrading-icinga-2.md | 69 +++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/doc/16-upgrading-icinga-2.md b/doc/16-upgrading-icinga-2.md index 187ffcb90..258a0e3d4 100644 --- a/doc/16-upgrading-icinga-2.md +++ b/doc/16-upgrading-icinga-2.md @@ -5,6 +5,12 @@ are scheme updates for the IDO database. ## Upgrading to v2.8 +### DB IDO Schema Update to 2.8.0 + +There are additional indexes and schema fixes which require an update. + +Please proceed here for [MySQL](16-upgrading-icinga-2.md#upgrading-mysql-db) for [PostgreSQL](16-upgrading-icinga-2.md#upgrading-postgresql-db). + ### Changed Certificate Paths The default certificate path was changed from `/etc/icinga2/pki` to @@ -149,8 +155,8 @@ systemctl restart icinga2 ## Upgrading the MySQL database -If you're upgrading an existing Icinga 2 instance, you should check the -`/usr/share/icinga2-ido-mysql/schema/upgrade` directory for an incremental schema upgrade file. +If you want to upgrade an existing Icinga 2 instance, check the +`/usr/share/icinga2-ido-mysql/schema/upgrade` directory for incremental schema upgrade file(s). > **Note** > @@ -158,25 +164,35 @@ If you're upgrading an existing Icinga 2 instance, you should check the Apply all database schema upgrade files incrementally. - # mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/upgrade/.sql +``` +# mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/upgrade/.sql +``` -The Icinga 2 DB IDO module will check for the required database schema version on startup -and generate an error message if not satisfied. +The Icinga 2 DB IDO feature checks the required database schema version on startup +and generates an log message if not satisfied. -**Example:** You are upgrading Icinga 2 from version `2.0.2` to `2.3.0`. Look into -the *upgrade* directory: +**Example:** You are upgrading Icinga 2 from version `2.4.0` to `2.8.0`. Look into +the `upgrade` directory: - $ ls /usr/share/icinga2-ido-mysql/schema/upgrade/ - 2.0.2.sql 2.1.0.sql 2.2.0.sql 2.3.0.sql +``` +$ ls /usr/share/icinga2-ido-mysql/schema/upgrade/ +2.0.2.sql 2.1.0.sql 2.2.0.sql 2.3.0.sql 2.4.0.sql 2.5.0.sql 2.6.0.sql 2.8.0.sql +``` -There are two new upgrade files called `2.1.0.sql`, `2.2.0.sql` and `2.3.0.sql` +There are two new upgrade files called `2.5.0.sql`, `2.6.0.sql` and `2.8.0.sql` which must be applied incrementally to your IDO database. +``` +# mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/upgrade/2.5.0.sql +# mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/upgrade/2.6.0.sql +# mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/upgrade/2.8.0.sql +``` + ## Upgrading the PostgreSQL database -If you're updating an existing Icinga 2 instance, you should check the -`/usr/share/icinga2-ido-pgsql/schema/upgrade` directory for an incremental schema upgrade file. +If you want to upgrade an existing Icinga 2 instance, check the +`/usr/share/icinga2-ido-mysql/schema/upgrade` directory for incremental schema upgrade file(s). > **Note** > @@ -184,17 +200,28 @@ If you're updating an existing Icinga 2 instance, you should check the Apply all database schema upgrade files incrementally. - # export PGPASSWORD=icinga - # psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/upgrade/.sql +``` +# export PGPASSWORD=icinga +# psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/upgrade/.sql +``` -The Icinga 2 DB IDO module will check for the required database schema version on startup -and generate an error message if not satisfied. +The Icinga 2 DB IDO feature checks the required database schema version on startup +and generates an log message if not satisfied. -**Example:** You are upgrading Icinga 2 from version `2.0.2` to `2.3.0`. Look into -the *upgrade* directory: +**Example:** You are upgrading Icinga 2 from version `2.4.0` to `2.8.0`. Look into +the `upgrade` directory: - $ ls /usr/share/icinga2-ido-pgsql/schema/upgrade/ - 2.0.2.sql 2.1.0.sql 2.2.0.sql 2.3.0.sql +``` +$ ls /usr/share/icinga2-ido-pgsql/schema/upgrade/ +2.0.2.sql 2.1.0.sql 2.2.0.sql 2.3.0.sql 2.4.0.sql 2.5.0.sql 2.6.0.sql 2.8.0.sql +``` -There are two new upgrade files called `2.1.0.sql`, `2.2.0.sql` and `2.3.0.sql` +There are two new upgrade files called `2.5.0.sql`, `2.6.0.sql` and `2.8.0.sql` which must be applied incrementally to your IDO database. + +``` +# export PGPASSWORD=icinga +# psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/upgrade/2.5.0.sql +# psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/upgrade/2.6.0.sql +# psql -U icinga -d icinga < /usr/share/icinga2-ido-pgsql/schema/upgrade/2.8.0.sql +```