[ZBX-6165] Error While Importing Template Created: 2013 Jan 22  Updated: 2017 May 30  Resolved: 2013 Jan 30

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Templates (T)
Affects Version/s: 2.0.4
Fix Version/s: None

Type: Incident report Priority: Major
Reporter: Gene Liverman Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: templates
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

CentOS 6.3 + EPEL, all updates applied
$ rpm -qa |grep zabbix
zabbix20-2.0.4-1.el6.x86_64
zabbix20-server-2.0.4-1.el6.x86_64
zabbix20-server-mysql-2.0.4-1.el6.x86_64
zabbix20-web-mysql-2.0.4-1.el6.noarch
zabbix20-agent-2.0.4-1.el6.x86_64
zabbix20-web-2.0.4-1.el6.noarch


Attachments: JPEG File TemplateImportError.jpg     XML File Template_Google_GSA.xml    
Issue Links:
Duplicate
duplicates ZBX-3783 Proper API validation Reopened

 Description   

While attempting to import a template, I get the following error:
Error in query [INSERT INTO hosts_groups (hostgroupid, hostid, groupid) VALUES (268, 10167, 1)] [Duplicate entry '10167-1' for key 'hosts_groups_1']
DBerror

The template I am trying to load is attached.



 Comments   
Comment by Gene Liverman [ 2013 Jan 22 ]

Attached screenshot of import screen.

Comment by richlv [ 2013 Jan 22 ]

have you been doing any direct database modifications now or at any point in the past ?
it does sound like ids getting out of sync.

if you do :

delete from ids where table_name='hosts_groups' and field_name='hostgroupid';

does it start working ?

Comment by Gene Liverman [ 2013 Jan 23 ]

I have not. As a matter of fact, when I went from 1.8 to 2.0 I was so paranoid about messing up the DB that I did a fresh install.

Comment by Gene Liverman [ 2013 Jan 25 ]

I realized that you wanted me to run that SQL statement either way so I did. When I did it as a select statement instead I got this:
mysql> select * from ids where table_name='hosts_groups' and field_name='hostgroupid';
-------------------------------------+

nodeid table_name field_name nextid

-------------------------------------+

0 hosts_groups hostgroupid 266

-------------------------------------+
1 row in set (0.00 sec)

When I ran it as a delete statement I got this:
mysql> delete from ids where table_name='hosts_groups' and field_name='hostgroupid';
Query OK, 1 row affected (0.01 sec)

After that, I tried importing again and got this error

Error in query [INSERT INTO hosts_groups (hostgroupid, hostid, groupid) VALUES (268, 10167, 1)] [Duplicate entry '10167-1' for key 'hosts_groups_1']
DBerror

Comment by Pavels Jelisejevs (Inactive) [ 2013 Jan 28 ]

Did you edit the XML file by hand? It's structure is incorrect. It has multiple groups and items tags.

Comment by Pavels Jelisejevs (Inactive) [ 2013 Jan 30 ]

It's a common problem with the API. When we call, for instance, host.create and pass duplicate host groups to a host, it will cause an SQL error. Same for other methods. It will be fixed in the trunk, not in 2.0.

CLOSED.

Generated at Sat Apr 26 05:40:45 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.