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.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Postgres Replication Lag Debugging Prompt
Diagnose streaming or logical replication lag from pg_stat_replication and pg_replication_slots — find where the bytes are stuck (send, write, flush, replay) and fix the cause without losing WAL or risking the primary.
-
Postgres Checkpoint & WAL Throughput Tuning Prompt
Smooth out checkpoint-driven I/O spikes and write stalls by tuning checkpoint, WAL, and full-page-write settings for the workload — without risking longer crash recovery than the RTO allows.
-
Postgres on Kubernetes Operator Troubleshooting Prompt
Diagnose a Postgres cluster managed by a Kubernetes operator (CloudNativePG, Crunchy PGO, Zalando) — stuck failovers, pods CrashLooping, PVC/storage issues, and split-brain risk — using operator status and pod logs.
-
Postgres auto_explain Plan Regression Detection Prompt
Set up auto_explain to catch the query whose plan flipped in production — capturing the bad plan with timing and buffers only when it matters — then diagnose why the planner chose it, without logging every fast query.
More Postgres prompts & error guides
Browse every Postgres prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.