We're upgrading our Postgresql from 9.6 to 14, using pglogical (latest installed via yum). The replication is working fine without errors. What we are not seeing, however, is any autovacuum activity on the v14 database, even though we continue to see normal autovacuum activity on the v9.6 database. Also, strangely, the dead tuple counts do not change on the v14 database and are mostly 0. I did run VACUUM ANALYZE
on the v14 database.
The command we are using to see autovacuum activity is
SELECT relname, last_vacuum, last_autovacuum, last_autoanalyze FROM pg_stat_user_tables;
The command we are using to see dead tuple counts is
SELECT relname, n_dead_tup FROM pg_stat_user_tables;
There's nothing in the logs except checkpoint notifications. Here is one line picked at random:
2022-09-22 11:59:46 PDT [2877]: [15846-1] user=,db=,app=,client= LOG: checkpoint complete: wrote 38220 buffers (0.9%); 0 WAL file(s) added, 0 removed, 17 recycled; write=269.923 s, sync=0.025 s, total=269.962 s; sync files=264, longest=0.007 s, average=0.001 s; distance=313936 kB, estimate=329901 kB
The v14 database is streaming to another v14 database acting as a replica.
Is this expected behavior?
After experimenting, it's clear that the n_dead_tup
counts are not updated while pglogical replication is running. This also means that autovacuum never runs while pglogical replication is running. Restarting the v14 node causes the n_dead_tup
counts to be updated and does trigger autovacuum, but that is a one time event (the tuples are not updated again until another restart).
Once you disable pglogical, the n_dead_tup
counts are immediately updated, and autovacuum starts to work again as expected (even without a restart).