Ad Widget

Collapse

Zabbix database bug. Need help with source code.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • quackduck
    Member
    • Feb 2025
    • 36

    #1

    Zabbix database bug. Need help with source code.

    I'm tryting to create a new "widget field" by add a new color (widget item) to a honeycomb widget. But I can't save the dashboard because the inserted widget field id already exists while trying to save the new widget item to the database.

    PHP Code:
    Error in query [INSERT INTO widget_field (widget_fieldid,widgetid,type,name,value_strVALUES ('185326','44775','1','thresholds.2.color','00FF00'), 
    Code:
    Error in query [INSERT INTO widget_field (widget_fieldid,widgetid,type,name,value_str) VALUES ('185326','44775','1','thresholds.2.color','00FF00'),('185327','44775','1','thresholds.2.threshold','-90')] [Duplicate entry '185326' for key 'widget_field.PRIMARY'] [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → CControllerDashboardUpdate->doAction() → CApiWrapper->__call() → CFrontendApiWrapper->callMethod() → CApiWrapper->callMethod() → CFrontendApiWrapper->callClientMethod() → CLocalApiClient->callMethod() → CDashboard->update() → CDashboardGeneral->updatePages() → CDashboardGeneral->updateWidgets() → CDashboardGeneral->updateWidgetFields() → DB::insert() → DB::insertBatch() → DBexecute() → trigger_error() in include/db.inc.php:362] SQL statement execution has failed "INSERT INTO widget_field (widget_fieldid,widgetid,type,name,value_str) VALUES ('185326','44775','1','thresholds.2.color','00FF00'),('185327','44775','1','thresholds.2.threshold','-90')".
    Now, how did this happen? I'm guessing that somewhere along the way, through insertion, imports, upgrades, backups or whatever, the ID counter of said index became lesser than the items that already exists.

    The database schema seem to not have a standard auto increment index counter so I can't just fast forward the auto increment index counter to something reasonable. Where is this counter implemented and how do I set it? I'm going through the source code, but no luck yet.

    Zabbix 7.0.
    Last edited by quackduck; 09-06-2025, 10:06.
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    There is a table "ids", which has last used ID-s for many (all?) tables... Due to some unforeseen circumstances, like crashes etc. it might sometimes get out of sync.. you can update it and it should start working again... (and no, I dont know why they call that field "nextid", even if it is the last one used... )

    Code:
    zabbix=# select widget_fieldid from widget_field order by widget_fieldid DESC limit 1;
    widget_fieldid
    ----------------
    58887
    
    zabbix=# select * from ids where table_name = 'widget_field';
    table_name | field_name | nextid
    --------------+----------------+--------
    widget_field | widget_fieldid | 58887

    Comment

    Working...