Ad Widget

Collapse

[7.4.6] Cannot delete hosts with discovered items

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cybermate
    Junior Member
    • Dec 2025
    • 2

    #1

    [7.4.6] Cannot delete hosts with discovered items

    Hello,

    When I try to delete a host, it fails.

    Code:
    pg_query(): Query failed: ERROR: update or delete on table "items" violates foreign key constraint "c_item_discovery_3" on table "item_discovery" DETAIL: Key (itemid)=(83660) is still referenced from table "item_discovery". [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → CControllerHostMassDelete->doAction() → CApiWrapper->__call() → CFrontendApiWrapper->callMethod() → CApiWrapper->callMethod() → CApiWrapper->callClientMethod() → CLocalApiClient->callMethod() → CHost->delete() → CHost::deleteForce() → CDiscoveryRule::deleteForce() → DB::delete() → DB::deleteByPkIds() → DB::deleteByIdField() → DBexecute() → pg_query() in include/db.inc.php:255]
    Error in query [DELETE FROM items WHERE itemid=83660]
    [ERROR: update or delete on table "items" violates foreign key constraint "c_item_discovery_3" on table "item_discovery"
    DETAIL: Key (itemid)=(83660) is still referenced from table "item_discovery".
    SQL statement execution has failed "DELETE FROM items WHERE itemid=83660"
    As I managed to delete a host with the ICMP ping template, I suppose it only happens on hosts with discovered items.
    Also, when I try to "unlink and clear" on a host, a similar error appears. I can only "unlink" the template without purging the data.

    I am certain that it worked before upgrading to version 7 (from 6.4). I suppose I could get around it with some messy SQL queries, but that would only be treating the symptoms.
    Is this a known issue? The result of a bad upgrade?​
    • Debian 13 ;
    • PostgreSQL 17 ;
    • Zabbix 7.4.6, installed via apt through the official repositories.

    Thank you,​
  • misak
    Junior Member
    • Feb 2013
    • 8

    #2
    I have similar problem:
    • pg_query(): Query failed: ERROR: update or delete on table "items" violates foreign key constraint "c_item_discovery_3" on table "item_discovery" DETAIL: Key (itemid)=(9339860) is still referenced from table "item_discovery". [zabbix.php:17 → require_once() → ZBase->run() → ZBase->processRequest() → CController->run() → CControllerHostMassDelete->doAction() → CApiWrapper->__call() → CFrontendApiWrapper->callMethod() → CApiWrapper->callMethod() → CApiWrapper->callClientMethod() → CLocalApiClient->callMethod() → CHost->delete() → CHost::deleteForce() → CDiscoveryRule::deleteForce() → DB::delete() → DB::deleteByPkIds() → DB::deleteByIdField() → DBexecute() → pg_query() in include/db.inc.php:255]
    • Error in query [DELETE FROM items WHERE itemid IN (9339860,9339861,9339862,9339863)] [ERROR: update or delete on table "items" violates foreign key constraint "c_item_discovery_3" on table "item_discovery" DETAIL: Key (itemid)=(9339860) is still referenced from table "item_discovery".]
    • SQL statement execution has failed "DELETE FROM items WHERE itemid IN (9339860,9339861,9339862,9339863)"

    Comment

    • cybermate
      Junior Member
      • Dec 2025
      • 2

      #3
      Do you know when this started happening?

      When Zabbix was at version 6.4 (dockerized), there was no problem, but then we upgraded to version 7 on a “standard” installation via apt, and since then we've had this problem.
      So we've just been disabling the hosts.

      Comment

      Working...