Runbook — Neon Postgres degraded
Database queries failing or pool exhausted. Most cases are connection storms (one bad migration / runaway worker) — kill the offender, verify pool recovers, then RCA.
| Field | Value |
|---|---|
| Severity | P0 |
| Owner | @aphaiboon |
| Alert source | Watchtower — cmmd_database_healthy == 0 for 1m OR pg_up{datname="cmmd"} == 0 |
| Estimated time | 5–30 min |
| Required access | Neon dashboard, Railway, SQL access via psql |
Symptom
Section titled “Symptom”Watchtower → Infra critical → Neon DB tile red. App returns 5xx on most routes. PostHog error rate spikes.
Most likely causes
Section titled “Most likely causes”- Connection pool exhausted — usually a runaway worker or stuck transactions. Look at
pg_stat_activity. - Neon platform incident — check the Neon status page tile on Watchtower home.
- Failed migration — recently merged migration locked a hot table or never completed.
- Compute auto-scaled down to zero (Neon free tier behavior on idle). Wakes on next query but causes 30s+ first-request latency.
Diagnose
Section titled “Diagnose”-
Open Neon dashboard → check compute state + active connections graph.
-
Check the Neon status page tile on Watchtower home.
-
From any developer machine with access:
-- Active connections by applicationSELECT application_name, state, count(*)FROM pg_stat_activityWHERE datname = 'cmmd'GROUP BY 1, 2;-- Long-running queries (suspect)SELECT pid, now() - query_start AS duration, state, queryFROM pg_stat_activityWHERE datname = 'cmmd'AND state != 'idle'AND now() - query_start > interval '30 seconds'ORDER BY duration DESC; -
If a single query is dominating: capture its text, then
SELECT pg_terminate_backend(<pid>);
Mitigate
Section titled “Mitigate”Connection storm
Section titled “Connection storm”- Identify the worst offender from
pg_stat_activityquery above. - Terminate the bad backend(s).
- Watch the pool: active connections should drop within seconds.
- If a CMMD background worker is the source: pause it in Railway until you can ship a fix.
Neon platform incident
Section titled “Neon platform incident”- Confirm on
status.neon.tech(or Neon status page tile in Watchtower home). - Inform in
#alerts— “Neon platform incident, customer impact:<scope>”. - There is no failover (single Neon project). Wait for Neon to restore. Capture timestamps + customer impact for postmortem.
Failed migration
Section titled “Failed migration”- Railway → check the latest deploy. If migration was the cause, the Railway deploy log will show the migration error.
- Roll back the deploy (which re-deploys with the prior migration head).
- Open an issue to fix the migration before re-attempting.
Verify resolved
Section titled “Verify resolved”cmmd_database_healthy == 1for 3 minutescurl -i https://cmmd.ai/healthreturns 200 with DB-backed payload populated
Escalate
Section titled “Escalate”- Neon dashboard shows account-level issues → email Neon support
- More than 15 min downtime → notify customers via status.cmmd.ai