Maintenance Windows
Maintenance windows are a contract with users and on-call engineers. Schedule high-impact Postgres work when blast radius is understood, communicated, and reversible.
Search across all documentation pages
Maintenance windows are a contract with users and on-call engineers. Schedule high-impact Postgres work when blast radius is understood, communicated, and reversible.
Quick-reference recipe card - copy-paste ready.
## Maintenance Notice Template
Window: 2026-07-12 02:00-04:00 UTC (low-traffic)
Impact: Up to 30s write latency spikes; no planned read outage
Changes: V2050 index rebuild, Patroni switchover rehearsal
Rollback: Revert migration V2050; DNS unchanged
Status page: https://status.example.com/incidents/42-- Pre-window: confirm no unexpected long transactions
SELECT count(*) FROM pg_stat_activity
WHERE state = 'idle in transaction'
AND now() - xact_start > interval '10 minutes';When to reach for this: High-risk DDL, failover drills, storage resize requiring restart, or pg_upgrade cutover.
Team schedules VALIDATE CONSTRAINT on 80M-row payments table during Sunday 03:00 UTC window.
# T-7 days: customer email + in-app banner
# T-1 day: freeze other high-risk changes
# T-0: on-call bridge open, scribe assignedSET lock_timeout = '3s';
SET statement_timeout = '2h';
ALTER TABLE payments VALIDATE CONSTRAINT payments_amount_positive;# Post-window: verify error rate and replication lag
psql -c "SELECT pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn) FROM pg_stat_replication;"What this demonstrates:
| Work type | Sizing hint |
|---|---|
CREATE INDEX CONCURRENTLY | 2-3x staging duration |
| Constraint validate | Table scan time + lock retry buffer |
| Failover drill | App cold-start storm + 15 min observation |
pg_upgrade | Vendor doc minimum + 100% buffer first time |
Pick windows from traffic dashboards, not only local time zone convenience.
| Say this | Not this |
|---|---|
| "Checkout may timeout for up to 60 seconds" | "Brief maintenance" |
| "Read-only mode for reporting API" | "No impact expected" |
| "Failover may drop in-flight transactions" | "Seamless upgrade" |
During the window:
-- Optional: revoke CREATE from app roles during window (extreme cases)
REVOKE CREATE ON SCHEMA public FROM app_migrator;| Alternative | Use When | Don't Use When |
|---|---|---|
| Online DDL only | Mature expand/contract culture | Emergency fix needs immediate rewrite |
| Blue/green database | Zero-downtime cutover budget | Small team without automation |
| Read-only window | Protect data during risky op | Writes required for revenue |
| Immediate change | Sev-1 mitigation | Planned schema improvement |
Monthly for medium-risk batch; ad hoc for high-risk; quarterly for DR drills.
Yes if any customer-facing API depends on the database.
Often yes for low tier; still notify on-call and monitor lag.
Incident Commander or change owner plus product duty officer.
Communicate new ETA; roll back if past rollback SLA.
Sometimes scale up connection workers after restart instead; plan per runbook.
Lowest global write TPS from metrics, not office location.
Yes. Treat them with the same comms and rollback rigor.
Error rate, p95 latency, replication byte lag, failed job queue depth.
See Uptime SLOs for Datastores for error budget alignment.
Stack versions: This page was written for PostgreSQL 18.4 (stable 18, maintenance 17), pgvector 0.8+, PgBouncer 1.x, Patroni 3.x, and PostGIS 3.5+.
Reviewed by Chris St. John·Last updated Jul 18, 2026