[ZBX-7025] Failed database migration due to a unique index between 1.8.17 and 2.0.8 Created: 2013 Sep 19 Updated: 2017 Oct 17 Resolved: 2017 Oct 17 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Server (S) |
Affects Version/s: | 1.8.17, 2.0.8 |
Fix Version/s: | None |
Type: | Incident report | Priority: | Critical |
Reporter: | Marc Schoechlin | Assignee: | Unassigned |
Resolution: | Unsupported version | Votes: | 0 |
Labels: | dbpatches, distributed, sql, upgrade | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
Ubuntu 12.04, MySQL 5.5.31 (distribution package), Node based Setup (two nodes), 6 proxies |
Description |
We are trying to perform a upgrade from 1.8.17 to 2.0.8 and we experience problems while applying the database patch. We performed the upgrade like described in: While executing the "patch.sql" we get the following message: # mysql zabbix20 < patch.sql ERROR 1062 (23000) at line 1119: Duplicate entry '200100000000278-200100000001803' for key 'items_applications_1' The problem is caused by the following statement: CREATE UNIQUE INDEX items_applications_1 ON items_applications (applicationid,itemid); I analyzed the table "items_applications": mysql> select applicationid,itemid, COUNT(*) as dupes from items_applications GROUP BY applicationid,itemid HAVING dupes > 1 ORDER BY dupes DESC; +-----------------+-----------------+-------+ | applicationid | itemid | dupes | +-----------------+-----------------+-------+ | 200100000000302 | 200100000001932 | 2 | | 200100000000584 | 200100000003503 | 2 | | 200100000000690 | 200100000006170 | 2 | | 200100000000754 | 200100000006530 | 2 | ..... ..... 185 rows in set (0.00 sec) mysql> select * from items_applications where applicationid=200100000000302 and itemid=200100000001932; +-----------------+-----------------+-----------------+ | itemappid | applicationid | itemid | +-----------------+-----------------+-----------------+ | 100100000050485 | 200100000000302 | 200100000001932 | | 200200000004417 | 200100000000302 | 200100000001932 | +-----------------+-----------------+-----------------+ 2 rows in set (0.01 sec) All rows which might cause problems with the unique index created by the migration script seems to have:
I removed "DROP INDEX items_applications_1.. " and "CREATE UNIQUE INDEX items_applications_1..." from "patch.sql" and kept the existing non-unique index on "applicationid" and "itemid". Please contact me - i can support you in examining the situation. |
Comments |
Comment by Oleksii Zagorskyi [ 2013 Sep 22 ] |
The "items_applications_1" index was mentioned there. |
Comment by Oleksii Zagorskyi [ 2013 Sep 22 ] |
But mixed node IDs for a single table row look indeed as another bug. |
Comment by Marc Schoechlin [ 2013 Sep 23 ] |
What can be the reason for mixed node IDs? The following statement returns 273 rows on the main server which have mixed ids: select itemappid,applicationid,itemid from items_applications where ((itemappid DIV 100000000000000) != (applicationid DIV 100000000000000)) OR ((applicationid DIV 100000000000000) != (itemid DIV 100000000000000)); If i remove the matched entries the patch.sql applies successfully! |