Alter DowntimeRemoval behaviour

This adds an additional index to the downtimehistory and updates the
dbevents in a way that it uses that index
This commit is contained in:
Jean Flach 2017-08-09 17:41:43 +02:00 committed by Michael Friedrich
parent 36fddaf09b
commit 30be02bcae
6 changed files with 59 additions and 6 deletions

View File

@ -29,7 +29,7 @@
#include <boost/thread/once.hpp>
#include <boost/thread/mutex.hpp>
#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

View File

@ -586,6 +586,7 @@ void DbEvents::RemoveDowntimeInternal(std::vector<DbQuery>& 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 */

View File

@ -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();

View File

@ -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();

View File

@ -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');

View File

@ -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');