Hi "Zabbixers",
I am setting up a structure with 1 zabbix server and 2 zabbix proxies.
I installed it with zabbix 7.4.2 and when I start the second proxy, I receive log messages in the database (postgresql 17) as follows:
I've already stopped both proxies and run the commands below:
Even so, when I start the proxies again, I get the duplicate key messages again!
What's going on, and how can I fix it?
I am setting up a structure with 1 zabbix server and 2 zabbix proxies.
I installed it with zabbix 7.4.2 and when I start the second proxy, I receive log messages in the database (postgresql 17) as follows:
2025-09-25 10:41:10.541 -03 [26947] ERROR: duplicate key value violates unique constraint "proxy_history_pkey"
2025-09-25 10:41:10.541 -03 [26947] DETAIL: Key (id)=(1516) already exists.
2025-09-25 10:41:10.541 -03 [26947] STATEMENT: insert into proxy_history (id,itemid,clock,timestamp,source,severity,value,l ogeventid,ns,state,lastlogsize,mtime,flags,write_c lock) values (1516,69880,1758807640,0,'',0,'2684780544',0,21992 5837,0,0,0,0,1758807640),(1517,69940,1758807640,0, '',0,'3937341440',0,220206696,0,0,0,0,1758807640);
2025-09-25 10:41:10.541 -03 [26947] DETAIL: Key (id)=(1516) already exists.
2025-09-25 10:41:10.541 -03 [26947] STATEMENT: insert into proxy_history (id,itemid,clock,timestamp,source,severity,value,l ogeventid,ns,state,lastlogsize,mtime,flags,write_c lock) values (1516,69880,1758807640,0,'',0,'2684780544',0,21992 5837,0,0,0,0,1758807640),(1517,69940,1758807640,0, '',0,'3937341440',0,220206696,0,0,0,0,1758807640);
I've already stopped both proxies and run the commands below:
DO
$$
DECLARE
seq RECORD;
tbl TEXT;
col TEXT;
max_id BIGINT;
BEGIN
FOR seq IN
SELECT
c.oid::regclass::text AS seqname,
n.nspname AS schemaname,
t.relname AS tablename,
a.attname AS colname
FROM pg_class c
JOIN pg_depend d ON d.objid = c.oid
JOIN pg_class t ON d.refobjid = t.oid
JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = d.refobjsubid
JOIN pg_namespace n ON n.oid = t.relnamespace
WHERE c.relkind = 'S'
AND d.classid = 'pg_class'::regclass
AND d.refclassid = 'pg_class'::regclass
AND n.nspname = 'public'
LOOP
tbl := seq.tablename;
col := seq.colname;
EXECUTE format('SELECT COALESCE(MAX(%I),0) FROM %I.%I', col, seq.schemaname, tbl)
INTO max_id;
RAISE NOTICE 'Resync sequence % -> next value %', seq.seqname, max_id+1;
EXECUTE format('SELECT setval(%L, %s, false)', seq.seqname, max_id+1);
END LOOP;
END
$$;
NOTICE: Resync sequence changelog_changelogid_seq -> next value 109199
$$
DECLARE
seq RECORD;
tbl TEXT;
col TEXT;
max_id BIGINT;
BEGIN
FOR seq IN
SELECT
c.oid::regclass::text AS seqname,
n.nspname AS schemaname,
t.relname AS tablename,
a.attname AS colname
FROM pg_class c
JOIN pg_depend d ON d.objid = c.oid
JOIN pg_class t ON d.refobjid = t.oid
JOIN pg_attribute a ON a.attrelid = t.oid AND a.attnum = d.refobjsubid
JOIN pg_namespace n ON n.oid = t.relnamespace
WHERE c.relkind = 'S'
AND d.classid = 'pg_class'::regclass
AND d.refclassid = 'pg_class'::regclass
AND n.nspname = 'public'
LOOP
tbl := seq.tablename;
col := seq.colname;
EXECUTE format('SELECT COALESCE(MAX(%I),0) FROM %I.%I', col, seq.schemaname, tbl)
INTO max_id;
RAISE NOTICE 'Resync sequence % -> next value %', seq.seqname, max_id+1;
EXECUTE format('SELECT setval(%L, %s, false)', seq.seqname, max_id+1);
END LOOP;
END
$$;
NOTICE: Resync sequence changelog_changelogid_seq -> next value 109199
Even so, when I start the proxies again, I get the duplicate key messages again!
What's going on, and how can I fix it?