FULL AI ANALYSIS

PostgreSQL standby reports 'invalid checksum' and stops applying WAL after incremental base backup restore

Generated Oct 19, 2026, 9:33:36 AM

Analysis summary

The standby error and small/partial WAL files indicate WAL corruption or a timeline mismatch. Corruption can come from partial rsync copies, archive rotation during a copy, or filesystem dedupe/truncate. A missing or incorrect timeline history file means WAL being applied belongs to a different timeline (eg. primary was promoted elsewhere then re‑integrated). If required WAL segments are lost or corrupted, the standby cannot continue and a new base backup is needed. If archives exist intact on primary or external backup, they should be retrieved; if not, rebuilding standby is likely.

Possible causes

WAL segment corruption from partial rsync/archive write (segments smaller than 16MB) causing checksum failure during apply

75%

Timeline/history mismatch (standby trying to apply WAL from a different timeline without corresponding .history), preventing proper WAL sequencing

60%

Restore_command reading from a mixed archive directory where older files were overwritten or pruned mid‑restore

45%

Filesystem or storage snapshot inconsistency causing bitrot or truncated files in archive area

30%

Suggested fixes

1

Diagnostic step 1

Stop the standby PostgreSQL instance to avoid further apply attempts and copy the entire pg_wal/pg_wal/archive status to a safe location for forensic investigation.

2

Diagnostic step 2

Run pg_waldump on the WAL segment reported bad to confirm corruption and note LSN ranges. Inspect archive dir timestamps and sizes for partial files (files < 16MB indicate truncation).

3

Diagnostic step 3

Check for timeline history files in archive; compare timeline IDs (pg_control, pg_controldata) between primary and standby. If history files missing, fetch them from primary or backups.

4

Diagnostic step 4

If intact WAL segments for the gap exist on the primary or an offsite archive, copy them into the archive and try restart. If necessary WAL segments are irretrievably corrupted/missing, take a new base backup (pg_basebackup) from primary and rebuild standby.

5

Diagnostic step 5

If unsure, escalate to a DBA: do not attempt forceful modifications to WAL or timeline files without backups (risk of data loss).