Skip to content
EL
Contents

Database reliability engineering

Will these action items prevent the next one?

DecisionExpert5 min read15 min hands-on#operations#concurrency

The idea in 30 seconds

After an incident, the action items decide whether it happens again. Items that add capacity, move work to quieter hours or name a person feel decisive and usually change nothing. Good items follow the actual mechanism of the failure: bound the wait that caused it, keep the work that triggered it off the critical path, and make the next one visible within a minute.

Helps to know first: Locks and locking strategies (coming soon), Vacuum, autovacuum and bloat (coming soon), Connection management and pooling (coming soon), Backups, restore and point-in-time recovery (coming soon)

On this page

The situation

Last Tuesday, checkout was down for 14 minutes. Your team lead wrote the postmortem and asks for your review before it is published.

Review taskPostmortem: checkout outage, 14 minutes

Timeline (UTC)

  • 13:51 A finance dashboard starts a 25-minute query on orders, on the primary database.
  • 14:02 A deploy runs the migration ALTER TABLE orders ADD COLUMN gift_message text;.
  • 14:02 Checkout requests start timing out. The migration has not finished.
  • 14:04 The database reports remaining connection slots are reserved and the app returns errors on every page.
  • 14:06 On-call cannot connect with the app’s credentials; finds an admin password at 14:12.
  • 14:16 On-call cancels the dashboard query. The migration completes instantly, and checkout recovers.

Root cause: the migration was too slow for a busy table. The deploying engineer should have checked the table’s size first.

Action items

  1. Raise max_connections from 200 to 1,000 so we never run out of connections again.
  2. Move the database to an instance with twice the CPU.
  3. Only run migrations between 02:00 and 04:00, when traffic is low.
  4. The deploying engineer to complete the migrations training.

Would you approve this postmortem? Write the review you would leave.

Your call

How to review action items

For each item, ask four questions:

Does it act on the mechanism? Trace the item through the timeline. If the incident would have unfolded the same way with the item in place, it is not a fix, however reasonable it sounds.

Is it a symptom or a cause? Running out of connections, high CPU and slow queries are usually what you saw. Ask what made them happen.

Will it still be true in a year? “Be more careful” and “only at night” decay as the team changes. A default in the migration tool, a role setting or an alert does not.

Does it make the next incident visible sooner? Even a perfect fix leaves other failures. Time to notice and time to get in are often most of the outage, as they were here.

Check yourself

  1. Why would raising max_connections to 1,000 not have shortened this outage?

    Show answer

    Connections ran out because every one was stuck in the lock queue. More slots would have let more requests join the same queue; nothing would have moved until the dashboard query ended.

  2. Which single change would have turned this outage into a failed deploy?

    Show answer

    Running the migration with a short lock_timeout. It would have given up after a few seconds, the checkout queries queued behind it would have run, and the deploy could be retried.

  3. What evidence would tell you that more CPU was the right fix in a different incident?

    Show answer

    Sessions in pg_stat_activity that are active with no wait event, or waiting on CPU-bound work, together with the host’s CPU near its limit. Sessions waiting on Lock point to contention, not capacity.

Finished reading?

Saved in this browser only.

Sources

Where each claim on this page comes from.

  1. 1.
    Site Reliability Engineering, Chapter 15: Postmortem Culture: Learning from Failure
    ReferenceJohn Lunney, Sue Lueder (Google)· Google's Postmortem Philosophy; Best Practice: Avoid Blame and Keep It Constructive

    Postmortems should be blameless and assume good intentions; the aim is to fix systems and processes, not people; preventive actions should reduce the likelihood or impact of recurrence.

  2. 2.
    PostgreSQL documentation: 1.2 Architectural Fundamentals
    Primary· §1.2 Architectural Fundamentals

    The PostgreSQL server starts a new process for each client connection.

  3. 3.
    PostgreSQL documentation: 9.27 System Information Functions and Operators
    Primary· §9.27.1 Session Information Functions: pg_blocking_pids

    Queued lock requests block later conflicting requests (soft block).

  4. 4.
    PostgreSQL documentation: 19.11 Client Connection Defaults
    Primary· §19.11.1 Statement Behavior

    lock_timeout and statement_timeout bound how long a statement waits for a lock or runs.

Go further

What to read next, and why it is worth the time.

  1. 1.
    Site Reliability Engineering, Chapter 15: Postmortem Culture: Learning from Failure
    ReferenceJohn Lunney, Sue Lueder (Google)

    How to run a postmortem that produces changes rather than blame, from a team that has run thousands.

Applies to PostgreSQL 18. Draft: not yet fact-checked end to end.