I have 2 PostgreSQL 16 instances in different location and I am trying to apply logical replication between couple of tables even there are thousands of tables in publisher site. I mean there are about 5000 tables in publisher site but I am using logical replication for only 60 tables
All the replicated tables are in sync as number of record count currently. I have checked with select count(*) from table
My problem is when I run following query I could see increasing huge replication lag and number of files in WAL directory increasing (number of wal files are 9952) If I drop subscription and replication slot, postgresql cleaning WAL directory
# SELECT
slot_name,
confirmed_flush_lsn,
pg_current_wal_lsn(),
(pg_current_wal_lsn() - confirmed_flush_lsn) AS lag
FROM pg_replication_slots;
slot_name | confirmed_flush_lsn | pg_current_wal_lsn | lag
-------------------------------------------+---------------------+--------------------+--------------
log_rep_slot | 6C5/2C77D4E0 | 6E7/F6A54B40 | 149420865120
pg_316283_sync_248141_7306809026670557899 | | 6E7/F6A54B40 |
pg_316283_sync_248213_7306809026670557899 | | 6E7/F6A54B40 |
pg_316283_sync_248175_7306809026670557899 | | 6E7/F6A54B40 |
pg_316283_sync_248194_7306809026670557899 | | 6E7/F6A54B40 |
pg_316283_sync_248206_7306809026670557899 | | 6E7/F6A54B40 |
pg_316283_sync_248232_7306809026670557899 | | 6E7/F6A54B40 |
pg_316283_sync_248159_7306809026670557899 | | 6E7/F6A54B40 |
pg_316283_sync_248147_7306809026670557899 | | 6E7/F6A54B40 |
pg_316283_sync_248129_7306809026670557899 | | 6E7/F6A54B40 |
pg_316283_sync_248165_7306809026670557899 | | 6E7/F6A54B40 |
(11 rows)
So why WAL files and replication lag are increasing even if all my replicated tables are in sync
All the replicated tables are in sync
- the presence of pg_316283_sync_* indicates the opposite - the initial datasync is in progress. Check the logs, pg_stat_subscription andselect srrelid::regclass, srsubstate from pg_subscription_rel