Thread: BUG #15468: vacuum command returns ERROR: cannot freeze committed xmax

BUG #15468: vacuum command returns ERROR: cannot freeze committed xmax

From
PG Bug reporting form
Date:
The following bug has been logged on the website:

Bug reference:      15468
Logged by:          Andriy Bartash
Email address:      banlex73@gmail.com
PostgreSQL version: 10.4
Operating system:   CentOS Linux release 7.5.1804 (Core)
Description:

Hello
I am running vacuum and getting
vacuum ntfn;
ERROR:  cannot freeze committed xmax 614477059
----- in postgres log with log_error_verbosity =verbose
2018-10-29 23:36:02.982 UTC [23010] (user=barclays) (db=barclays)
(rhost=10.203.163.187) [vxid:193/3945120 txid:0] [SELECT] LOCATION:
exec_execute_message, postgres.c:2045
2018-10-29 23:36:05.721 UTC [32145] (user=postgres) (db=barclays)
(rhost=[local]) [vxid:272/1617334 txid:0] [VACUUM] ERROR:  XX001: cannot
freeze committed xmax 614477059
2018-10-29 23:36:05.721 UTC [32145] (user=postgres) (db=barclays)
(rhost=[local]) [vxid:272/1617334 txid:0] [VACUUM] LOCATION:
heap_prepare_freeze_tuple, heapam.c:6769
2018-10-29 23:36:05.721 UTC [32145] (user=postgres) (db=barclays)
(rhost=[local]) [vxid:272/1617334 txid:0] [VACUUM] STATEMENT:  vacuum
ntfn;

I found that error in my log 10 days ago.
What I checked be before I file this report:
1. Long-running transactions (nothing found)
     SELECT pid, datname, usename, state, backend_xmin
     FROM pg_stat_activity
     WHERE backend_xmin IS NOT NULL
     ORDER BY age(backend_xmin) DESC;
2.Abandoned replication slots: 
Yes we have 3 physical replication slots and all are active. All slots
session were terminated and recreated automatically (didn't help)
select slot_name, active, slot_type, restart_lsn FROM pg_replication_slots
where slot_type='physical';
              slot_name              | active | slot_type | restart_lsn  
-------------------------------------+--------+-----------+--------------
 postgres_prd_europewest2_emeaprd0_2 | t      | physical  | A78/7A76A8A8
 postgres_prd_europewest2_emeaprd0_0 | t      | physical  | A78/7A720000
 postgres_prd_europewest3_emeaprd0_1 | t      | physical  | A78/7A69FE88

3. Orphaned prepared transactions:
 SELECT gid, prepared, owner, database, transaction AS xmin
 FROM pg_prepared_xacts
 ORDER BY age(transaction) DESC;
 gid | prepared | owner | database | xmin 
-----+----------+-------+----------+------
(0 rows)

Thank you in advance
Andriy