While performing upgrade from Zabbix 5.0 LTS to Zabbix 6.0 LTS, there is issue with actual data in table "history_uint" and new primary keys created by "history_pk_prepare.sql".
Tables "history*" are large (>500 GB), that's why before upgrade process I renamed them with suffix "_old_table" and created new empty tables with default naming and same structure. So upgrade process could be a lot faster. After successful upgrade tried to insert old data back with:
For almost all tables this approach worked, except "history_uint" - because of existing duplicate data on columns "itemid", "clock", "ns", which are used by new multicolumn primary key "history_uint_pkey".
Data cannot be inserted from old table "history_uint_old_table" into table "history_uint":
Found duplicate values with SQL:
They all come from one Zabbix item (Zabbix Agent active):
Issue arises sometimes when there is 100 new item values per second (it newer reaches more values - looks like limitation on Zabbix server side) from Zabbix Agent active and Zabbix server processes two of them on the same nano second.
What would You suggest as fix for this problem ?
Tables "history*" are large (>500 GB), that's why before upgrade process I renamed them with suffix "_old_table" and created new empty tables with default naming and same structure. So upgrade process could be a lot faster. After successful upgrade tried to insert old data back with:
Code:
INSERT INTO history selec * from history_old_stable;
Data cannot be inserted from old table "history_uint_old_table" into table "history_uint":
Code:
INSERT INTO history_uint SELECT * FROM history_uint_old_table; ERROR: duplicate key value violates unique constraint "history_uint_pkey" DETAIL: Key (itemid, clock, ns)=(1442, 1657527245, 687061700) already exists.
Code:
SELECT itemid, clock, ns, COUNT(*) FROM history_uint GROUP BY itemid, clock, ns HAVING COUNT(*) > 1 ORDER BY COUNT desc;
Code:
logrt[C:\app\file.log,"Query speed:"]
What would You suggest as fix for this problem ?
Comment