Good day!
CentOS 8.1.1911, zabbix 4.4.7, postgresql 10.6, PHP 7.2.11, Apache 2.4.37
An error occurs while deleting the host. New nodes are created without problems. When you disable the template with cleaning, a similar error appears. Without cleaning, templates are disabled without problems.
Tell me how to solve this problem? Screenshots of errors in the attachment.
The full text of the error when deleting the node:

Best regards, Dmitry
CentOS 8.1.1911, zabbix 4.4.7, postgresql 10.6, PHP 7.2.11, Apache 2.4.37
An error occurs while deleting the host. New nodes are created without problems. When you disable the template with cleaning, a similar error appears. Without cleaning, templates are disabled without problems.
Tell me how to solve this problem? Screenshots of errors in the attachment.
The full text of the error when deleting the node:
- pg_query(): Query failed: ERROR: update or delete on table "items" violates foreign key constraint "item_discovery_itemid_fkey" on table "item_discovery"
- ???????????: Key (itemid)=(51428) is still referenced from table "item_discovery". [hosts.php:832 → CApiWrapper->__call() → CFrontendApiWrapper->callMethod() → CApiWrapper->callMethod() → CFrontendApiWrapper->callClientMethod() → CLocalApiClient->callMethod() → CHost->delete() → CDiscoveryRule->delete() → CItemPrototypeManager::delete() → CItemManager::delete() → DB::delete() → DBexecute() → pg_query() in include/db.inc.php:487]
- Error in query [DELETE FROM items WHERE (itemid IN ('51428','51429','51430','51431','51432','51433',' 51434','51435','51436','51437','51438','51439','51 440','51441','51442','51443','51444','51445','5144 6','51447','51448','51449','51450','51451','51452' ,'51453','51454','51455','51456','51457','51458',' 51459','51460','51461','51462','51463','51464','51 465','51466','51467','51468','51469','51470','5147 1','51472','51473','51474','51475','51476','51477' ,'51478','51479','51480','51481','51482','51483',' 51484','51485','51486','51487','51488','51489','51 490','51491','51492','51493','51494','51495','5149 6','51497','51498','51499','51500','51501','51502' ,'51503','51504','51505','51506','51507','51508',' 51509','51510','51511','51512','51513','51514','51 515','51516','51517','51518','51519','51520','5152 1','51522','51523','51524','52078','52093','52094' ,'52095','52096','52097','52098','52099','52100',' 52101','52102','52103','52104','52105','52106','52 107','52108','52109'))] [ERROR: update or delete on table "items" violates foreign key constraint "item_discovery_itemid_fkey" on table "item_discovery"
- ???????????: Key (itemid)=(51428) is still referenced from table "item_discovery".]
- Ошибка при выполнении SQL запроса "DELETE FROM items WHERE (itemid IN ('51428','51429','51430','51431','51432','51433',' 51434','51435','51436','51437','51438','51439','51 440','51441','51442','51443','51444','51445','5144 6','51447','51448','51449','51450','51451','51452' ,'51453','51454','51455','51456','51457','51458',' 51459','51460','51461','51462','51463','51464','51 465','51466','51467','51468','51469','51470','5147 1','51472','51473','51474','51475','51476','51477' ,'51478','51479','51480','51481','51482','51483',' 51484','51485','51486','51487','51488','51489','51 490','51491','51492','51493','51494','51495','5149 6','51497','51498','51499','51500','51501','51502' ,'51503','51504','51505','51506','51507','51508',' 51509','51510','51511','51512','51513','51514','51 515','51516','51517','51518','51519','51520','5152 1','51522','51523','51524','52078','52093','52094' ,'52095','52096','52097','52098','52099','52100',' 52101','52102','52103','52104','52105','52106','52 107','52108','52109'))"
Best regards, Dmitry