Diagnostic step 1
Confirm which WAL segments are missing by inspecting primary's pg_wal and archive directory and checking replica's last WAL LSN in recovery logs; do not attempt to manipulate WAL files on disk without backups.
Generated Oct 3, 2026, 12:35:03 AM
Confirm which WAL segments are missing by inspecting primary's pg_wal and archive directory and checking replica's last WAL LSN in recovery logs; do not attempt to manipulate WAL files on disk without backups.
If missing WALs are irrecoverable, take a fresh base backup from primary (pg_basebackup) and reinitialize the replica; this is the safest recovery path when required WALs are gone.
Before future heavy WAL operations: ensure archive_command is reliable and monitored, increase wal_keep_size (or enable sufficient retention), and consider running pg_repack with chunking and lower maintenance_work_mem to spread WAL over a longer period.
Run pg_repack during a maintenance window with replica paused or with promoted standby available; consider using logical replication for schema changes that would otherwise cause large WAL churn.
If you require assistance preserving forensic WAL segments, consider engaging a DBA with access to archived WAL storage; escalate to specialist if archive integrity or hardware failure is suspected.