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

Mysql Duplicate Entry when adding a new host with a template, or when linking a template to an existing host : "Duplicate Entry in key 1 of table events").

XMLWordPrintable

    • Icon: Incident report Incident report
    • Resolution: Won't fix
    • Icon: Major Major
    • None
    • 2.0.1
    • Frontend (F), Server (S)
    • Suse Linux
      Mysql 5.0
      Apache 2
      PHP 5

      The table ids is not correctly updated by zabbix-server
      So that we have the auto-increment column "eventid" from the table "events" equal or greater than the corresponding "nextid" from the table "ids".
      the sql code below shows the problem and how to manually solve it (we have put a cron doing that each minute).
      The problem is blocking when adding a new host with a template, or when linking a template to an existing host (we obtain a mysql problem saying : "Duplicate Entry in key 1 of table events").

      mysql> select max(eventid) from events; select * from ids where table_name='events'; update ids set nextid=((select max(eventid) from events) + 1 ) where table_name='events'; select max(eventid) from events; select * from ids where table_name='events';
      --------------
      select max(eventid) from events
      --------------

      --------------

      max(eventid)

      --------------

      48297

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

      --------------
      select * from ids where table_name='events'
      --------------

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

      nodeid table_name field_name nextid

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

      0 events eventid 48297

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

      --------------
      update ids set nextid=((select max(eventid) from events) + 1 ) where table_name='events'
      --------------

      Query OK, 1 row affected (0.03 sec)
      Rows matched: 1 Changed: 1 Warnings: 0

      --------------
      select max(eventid) from events
      --------------

      --------------

      max(eventid)

      --------------

      48297

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

      --------------
      select * from ids where table_name='events'
      --------------

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

      nodeid table_name field_name nextid

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

      0 events eventid 48298

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

            Unassigned Unassigned
            nizaros Nizar TLILI
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: