FULL AI ANALYSIS

Primary PostgreSQL WAL directory fills after interrupted base backup and failing archive_command

Generated Oct 21, 2026, 9:46:27 AM

Analysis summary

WAL retention is functioning as designed: PostgreSQL refuses to remove WAL segments that might still be required by standbys or that haven't been archived successfully. The interrupted base backup likely left a timeline or gap; combined with failing archive_command (S3 credential rotation) the server retains WAL. The safest corrective actions are to restore archive_command functionality so archiving completes, or if standbys are permanently disconnected, take a fresh base backup for replicas and then safely archive/prune WAL.

Possible causes

Archive_command failing (S3 credential rotation / permissions) preventing WAL from being archived and removed

85%

Interrupted base backup / timeline switch requiring older WAL segments for standby recovery

60%

Standbys disconnected and lagging, still requesting older WAL segments

50%

Misuse of pg_archivecleanup or manual deletion attempted while replicas still need WAL

30%

Suggested fixes

1

Diagnostic step 1

Do NOT delete WAL files manually while replicas may need them. Check pg_stat_replication and pg_stat_archiver to identify minimal required WAL.

2

Diagnostic step 2

Fix archive_command (restore correct S3 credentials / permissions) so existing WAL segments can be archived; confirm by observing successful archive entries in wal-e logs.

3

Diagnostic step 3

If replicas cannot be reconnected or are obsolete, take a fresh base backup of primary and reinitialize standbys; only then you can safely remove older WAL segments.

4

Diagnostic step 4

If immediate disk relief needed, copy WAL segments to external storage (tar up pg_wal) and mount that archive as temporary offline safe store before pruning locally — but only after ensuring no standby relies on them.

5

Diagnostic step 5

Document the sequence and automate archive validity checks; consider increasing archive throughput or offsite capacity to avoid reoccurrence.