PostgreSQL standby stops applying WAL after pg_basebackup restore — replication slot grows and disk fills
Environment
Primary: PostgreSQL 14.8 on Ubuntu 20.04 (bare-metal); Standby created with pg_basebackup and archive/replication slots enabled. Primary performs continuous WAL archiving to a remote archive_command. Replication uses streaming with replication slot 'standby_slot'.
Symptoms
Standby initially follows primary, then stops applying WALs. The replication slot on primary grows indefinitely; 'pg_stat_replication' shows the standby connected but 'sent_lsn' advances while 'replay_lsn' on standby is stuck. WAL archive directory on primary continues to accumulate WAL files and disk usage approaches capacity.
Observations
On the standby, postgresql.conf shows restore_command configured, timeline history file present. 'SELECT pg_last_wal_receive_lsn(), pg_last_wal_replay_lsn()' shows receive > replay. Standby logs contain repeated 'could not open file
Already attempted
Restarted standby PostgreSQL service — after restart it resumed applying WAL temporarily then stalled again. Verified archive_command success on primary and file permissions. Ran 'pg_controldata' on replica basebackup directory — timeline and redo LSN consistent with primary at backup time. Cleared and re-copied archive_command result for a single missing WAL segment — standby immediately applied it. Enabled increased logging on standby for recovery and checked for I/O or permission errors — none obvious.
Question
Why does the standby stop applying WAL despite receiving them (receive_lsn > replay_lsn) and what safe remediation prevents replication slot growth without reinitializing the standby from scratch?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags
- Databases40% match
PostgreSQL standby stops applying WAL during long-running transactions on primary after pg_basebackup restore
Open0 answers - Databases39% match
PostgreSQL replica stops streaming WAL after pg_repack on primary; replication slot reports missing WAL
Open0 answers - Databases38% match
PostgreSQL standby stops applying WAL with 'invalid record length' after pg_upgrade and manual archive restore
Open0 answers - Databases35% match
PostgreSQL WAL archiving stalls during pg_basebackup when archive_command uses rsync over SSH
Open0 answers - Databases35% match
PostgreSQL logical replication slot grows until disk full after subscriber disconnects during nightly load
Open0 answers