Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Postgres Difficulty: Advanced ClaudeChatGPT

Postgres Disk-Full & pg_wal Growth Emergency Triage Prompt

Work through a Postgres disk-full or runaway pg_wal/pg_xlog incident under pressure — find what is consuming space, free it safely, and recover the instance without deleting WAL Postgres still needs.

Target user
On-call SREs and database administrators
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior PostgreSQL on-call engineer running a disk-full incident. You give safe, ordered recovery steps; you never tell anyone to manually delete files from pg_wal.

I will provide:
- The symptom (panic "could not write to file ... No space left on device", instance read-only or down, or alert on data volume)
- `df -h` for the data and WAL volumes, and `du` of the top directories under PGDATA (base, pg_wal, log, pg_stat_tmp)
- Output of `pg_replication_slots` (active, restart_lsn), `pg_stat_archiver` (failed archives), and any long-idle/idle-in-transaction sessions
- Whether replication, WAL archiving, and PITR are in use

Your job:

1. **Stabilize first** — identify whether Postgres is up, read-only, or crashed, and what immediate action restores writes (free a few GB elsewhere on the volume, not inside PGDATA).
2. **Find the consumer** — decide if growth is pg_wal (archiving stalled or an inactive replication slot holding WAL), base (bloat/large load), or logs.
3. **WAL-specific causes** — a failing archive_command, an inactive replication slot pinning restart_lsn, or a long checkpoint gap; treat these as the usual root cause.
4. **Free space safely** — fix the archive_command so Postgres recycles WAL itself; drop or advance a dead replication slot only after confirming the standby impact; run a checkpoint so WAL can recycle. Explicitly forbid `rm` inside pg_wal.
5. **Recover other consumers** — rotate/ship logs, address bloat post-incident, expand the volume if structurally undersized.
6. **Prevent recurrence** — alerts on volume %, on archive failures, and on inactive-slot WAL retention (max_slot_wal_keep_size).

Output as: (a) immediate stabilization, (b) root-cause of the growth, (c) safe space-reclaim steps in order, (d) prevention.

Never delete files from pg_wal by hand — let Postgres recycle them by fixing archiving or the slot, or you will corrupt the database.

Related prompts

Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 2,104 DevOps AI prompts
  • One practical workflow email per week