Icinga / icingaweb2-module-idoreports

Icinga IDO Reports provides host and service availability reports for Icinga based on the monitoring database (IDO).
GNU General Public License v2.0
34 stars 13 forks source link

PostgreSQL "ERROR: result of range difference would not be contiguous" depending on Timeframe #50

Closed wferi closed 2 years ago

wferi commented 3 years ago

Describe the bug

Asking for a "one week" host SLA report produces the following stack trace:

SQLSTATE[22000]: Data exception: 7 ERROR:  result of range difference would not be contiguous
CONTEXT:  SQL function "idoreports_get_sla_ok_percent" statement 1, query was: SELECT h.display_name AS host_display_name, h.display_name AS host_display_name, idoreports_get_sla_ok_percent(ho.object_id, '2021-06-26 13:15:38', '2021-07-03 13:15:38', NULL) AS sla FROM icinga_objects AS ho
 INNER JOIN icinga_hosts AS h ON h.host_object_id = ho.object_id AND ho.is_active = 1 AND ho.objecttype_id = 1 ORDER BY LOWER(h.display_name) ASC (Pdo.php:225)

#0 /usr/share/icingaweb2/library/vendor/Zend/Db/Statement.php(297): Zend_Db_Statement_Pdo->_execute(Array)
#1 /usr/share/icingaweb2/library/vendor/Zend/Db/Adapter/Abstract.php(470): Zend_Db_Statement->execute(Array)
#2 /usr/share/icingaweb2/library/vendor/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT h.displa...', Array)
#3 /usr/local/share/icingaweb2/modules/idoreports/library/Idoreports/IdoReport.php(191): Zend_Db_Adapter_Pdo_Abstract->query(Object(Zend_Db_Select))
#4 /usr/local/share/icingaweb2/modules/idoreports/library/Idoreports/HostSlaReport.php(86): Icinga\Module\Idoreports\IdoReport->fetchHostSla(Object(Icinga\Module\Reporting\Timerange), Array)
#5 /usr/local/share/icingaweb2/modules/idoreports/library/Idoreports/IdoReport.php(30): Icinga\Module\Idoreports\HostSlaReport->fetchSla(Object(Icinga\Module\Reporting\Timerange), Array)
#6 /usr/local/share/icingaweb2/modules/reporting/library/Reporting/Report.php(293): Icinga\Module\Idoreports\IdoReport->getHtml(Object(Icinga\Module\Reporting\Timerange), Array)
#7 /usr/local/share/icingaweb2/modules/reporting/application/controllers/ReportController.php(42): Icinga\Module\Reporting\Report->toHtml()
#8 /usr/share/icingaweb2/library/vendor/Zend/Controller/Action.php(507): Icinga\Module\Reporting\Controllers\ReportController->indexAction()
#9 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(76): Zend_Controller_Action->dispatch('indexAction')
#10 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response))
#11 /usr/share/php/Icinga/Application/Web.php(300): Zend_Controller_Front->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response))
#12 /usr/share/php/Icinga/Application/webrouter.php(104): Icinga\Application\Web->dispatch()
#13 /usr/share/icingaweb2/public/index.php(4): require_once('/usr/share/php/...')
#14 {main}

To Reproduce

Steps to reproduce the behavior:

  1. Create the most basic Host SLA report: One Week (or One Month, One Year, Last Day, Last Month, Current Year, Last Year), no template, no filter, no breakdown, no threshold.
  2. Click on it and behold the above "Data exception".
  3. Change the Timeperiod to 4 Hours, 25 Hours, Current Day, Last Day, Current Week, Current Month.
  4. A report now works.

Expected behavior

The report should work with any Timeframe.

Your Environment

Spikelite commented 2 years ago

We have the same behavior on our platform. Exact same error message.

nilmerg commented 2 years ago

Fixed by #52