Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-19790

PlainText widget slow query

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • 5.4.3
    • Frontend (F)
    • None

      Steps to reproduce:

      1. Create dashboard in any template assigned to host
      2. Add widget with simple text and select one item, which have long history
      3. Save dashboard and open it for view.

      Result:

      • Slow loading of widgets
      • Massive consumption of memory and CPU by PostgreSQL

      Example of failing query:

      SQL (3.824089): SELECT MAX(h.clock) FROM history_uint h WHERE h.itemid='871275'
      zabbix.php:22 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → CControllerWidgetPlainTextView->doAction() → CHistoryManager->getLastValues() → CHistoryManager->getLastValuesFromSql() → DBselect() in include/classes/api/managers/CHistoryManager.php:215
      

      After quick and dirty hack

      --- app/controllers/CControllerWidgetPlainTextView.php.orig     2021-08-09 16:46:10.322546019 +0700
      +++ app/controllers/CControllerWidgetPlainTextView.php  2021-08-09 16:46:24.160616626 +0700
      @@ -91,7 +91,7 @@
                                      // macros
                                      $items = CMacrosResolverHelper::resolveItemNames($items);
       
      -                               $histories = Manager::History()->getLastValues($items, $fields['show_lines']);
      +                               $histories = Manager::History()->getLastValues($items, $fields['show_lines'], 86400);
       
                                      if ($histories) {
                                              $histories = call_user_func_array('array_merge', $histories);
      

      the page loads much faster and resource consumption is normal.
      SQL query is:

      SQL (0.001613): SELECT MAX(h.clock) FROM history_uint h WHERE h.itemid='870891' AND h.clock>1628413643
      zabbix.php:22 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → CControllerWidgetPlainTextView->doAction() → CHistoryManager->getLastValues() → CHistoryManager->getLastValuesFromSql() → DBselect() in include/classes/api/managers/CHistoryManager.php:215
      

       

      The problem is possible similar to Latest data recent problems.

            zabbix.dev Zabbix Development Team
            Raifeg Pavel Stepanov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: