Home›Operate›Something is slow or broken

Something is slow or broken

You are on call and the database is on fire. What do you actually do?

These are the playbooks I would want next to me during an outage. Start with the first five minutes, then open the symptom you see. Each playbook goes from confirming the problem, to finding the cause, to stopping the bleeding with the least risky move first, with the commands for your engine, what to look for and where to go next. It also says when to escalate, when to get the application team on a call and what to suggest to them, what to post in the channel, and what the postmortem should change.

Every incident

The first five minutes

Before any playbook below, whatever the symptom. This is what separates a 20 minute incident from a 3 hour one.

  1. Is it the database at all?

    Look at the app's error rate and latency next to the database's CPU, connections and query time. If only one app is hurting and the database graphs are flat, it is probably that app, its network or its pool. Say so early: it saves everyone an hour. On RDS or Aurora, also look at the RDS events: a failover or maintenance shows there first. On Kubernetes, look at pod restarts and recent rollouts.

  2. How wide, and since when?

    Primary or replicas, one cluster or all of them, every app or one. Find the minute the graph bent. That timestamp is the most useful fact of the incident.

  3. What changed just before that minute?

    Deploys, migrations, config changes, feature flags, batch jobs, a traffic spike, a failover, cloud maintenance. Most outages follow a change, and undoing the change is usually the fastest fix.

  4. Open the incident and say who drives

    One channel. One person drives the database, one talks to everyone else. Post: what is broken, what you are doing, when the next update comes. Then keep that promise.

  5. Save the evidence before you change anything

    Killing sessions and restarting destroys the clues. Thirty seconds of snapshots now is the difference between a root cause and a guess in the postmortem.

    PostgreSQL · shell
    F=/tmp/incident-$(date +%Y%m%d-%H%M)
    psql -XAt -F'|' -c "SELECT now(), pid, usename, application_name, client_addr, state,
      wait_event_type, wait_event, xact_start, query_start, left(query, 300)
      FROM pg_stat_activity" > $F-activity.txt
    psql -XAt -F'|' -c "SELECT pid, pg_blocking_pids(pid), wait_event, left(query, 200)
      FROM pg_stat_activity WHERE cardinality(pg_blocking_pids(pid)) > 0" > $F-blocking.txt
    psql -XAt -c "SELECT * FROM pg_stat_replication" > $F-replication.txt
    MySQL · shell
    F=/tmp/incident-$(date +%Y%m%d-%H%M)
    mysql -e "SHOW FULL PROCESSLIST" > $F-processlist.txt
    mysql -e "SHOW ENGINE INNODB STATUS\G" > $F-innodb.txt
    mysql -e "SELECT * FROM sys.innodb_lock_waits\G" > $F-lockwaits.txt
    mysql -e "SHOW REPLICA STATUS\G" > $F-replica.txt
    MongoDB · shell
    F=/tmp/incident-$(date +%Y%m%d-%H%M)
    mongosh --quiet --eval 'printjson(db.currentOp(true))' > $F-currentop.json
    mongosh --quiet --eval 'printjson(db.serverStatus())' > $F-serverstatus.json
    mongosh --quiet --eval 'printjson(rs.status())' > $F-rs.json
  6. One change at a time, written down

    Post each action with its time in the channel. Two changes at once means you will not know which one fixed it, or which one made it worse.

By symptom

Open the playbook for what you see

Your engine
Runs on
Too many connectionsNew connections fail with "too many connections" (MySQL, PostgreSQL) or the app's pool times out waiting for one. Often right after a deploy, a failover or a traffic spike.Open the playbookClose · 8 steps
You are here if
  • "too many connections" (MySQL) or "remaining connection slots are reserved" (PostgreSQL) in app logs
  • Pool timeouts in the app: "timed out waiting for a connection"
  • Connections above 80 percent of the limit
  • Often right after a deploy, an autoscaling event or a failover

Start here. Get in on a reserved slot, then find which app owns the connections and what state they are in. The state tells you which outage this really is.

Likely causes, most common first
  1. Each app instance opens its own pool, and instances × pool size went past the server limit. A deploy that doubles instances for a few minutes is enough.
  2. Connections are held while idle in a transaction, so the pool runs dry while the database is mostly idle.
  3. Queries got slower, so each connection is busy longer and more are needed for the same traffic.
  4. Clients reconnect all at once after a failover or restart.
Confirm and scope
  1. 1Get in, and measure how close to the limit you areOnly reads

    You need a session of your own before you can fix anything. Both engines keep room for an admin.

    PostgreSQL
    SELECT count(*) AS in_use,
           current_setting('max_connections') AS max,
           current_setting('superuser_reserved_connections') AS reserved_for_admins
    FROM pg_stat_activity WHERE backend_type = 'client backend';
    MySQL
    SHOW VARIABLES LIKE 'max_connections';
    SHOW GLOBAL STATUS WHERE Variable_name IN
      ('Threads_connected', 'Threads_running', 'Max_used_connections',
       'Connection_errors_max_connections');
    MongoDB
    db.serverStatus().connections   // current, available, totalCreated

    Look for: In use within a few of the limit confirms it. PostgreSQL keeps superuser_reserved_connections for superusers: connect as postgres on the host. MySQL allows one extra connection for an account with CONNECTION_ADMIN.

Find the cause
  1. 2Group the connections by app and stateOnly reads

    This one query decides the rest of the incident.

    PostgreSQL
    SELECT usename, application_name, client_addr, state, count(*)
    FROM pg_stat_activity WHERE backend_type = 'client backend'
    GROUP BY 1, 2, 3, 4 ORDER BY 5 DESC LIMIT 20;
    MySQL
    SELECT user, SUBSTRING_INDEX(host, ':', 1) AS client, command, count(*)
    FROM information_schema.processlist
    GROUP BY 1, 2, 3 ORDER BY 4 DESC LIMIT 20;
    MongoDB
    db.getSiblingDB('admin').aggregate([
      { $currentOp: { allUsers: true, idleConnections: true } },
      { $group: { _id: { app: '$appName', client: '$client' }, n: { $sum: 1 } } },
      { $sort: { n: -1 } }, { $limit: 20 }])

    Look for: Read the state column for the biggest group.

  2. 3Line it up with what changedOnly reads

    A deploy that doubled the pods, a new service, a failover that made every client reconnect at once.

    In the shell
    # kubectl: did the replica count of an app change?
    kubectl get hpa -A
    kubectl rollout history deployment/<app> -n <namespace>

    Look for: Pods times pool size, before and after the change. If the new number is over the limit, you have the cause.

Stop the bleeding, least risky first
  1. 4End sessions stuck idle in a transactionLow-risk changeTime box: 5 minutes

    They hold connections and locks and do nothing. Ending them is safe: their open transaction rolls back and the app gets an error on a connection it was not using.

    PostgreSQL
    SELECT pid, usename, application_name,
           now() - xact_start   AS transaction_age,
           now() - state_change AS idle_for,
           left(query, 80)      AS last_query
    FROM pg_stat_activity WHERE state = 'idle in transaction'
    ORDER BY xact_start LIMIT 20;
    
    -- then end the ones idle for more than 5 minutes
    SELECT pid, pg_terminate_backend(pid)
    FROM pg_stat_activity
    WHERE state = 'idle in transaction'
      AND now() - state_change > interval '5 minutes';
    MySQL
    -- a transaction with no running query, and a Sleep thread, is idle in transaction
    SELECT t.trx_mysql_thread_id AS thread, t.trx_started,
           TIMESTAMPDIFF(SECOND, t.trx_started, NOW()) AS age_s, p.user, p.host
    FROM information_schema.innodb_trx t
    JOIN information_schema.processlist p ON p.id = t.trx_mysql_thread_id
    WHERE p.command = 'Sleep' ORDER BY t.trx_started LIMIT 20;
    
    -- then: KILL <thread>; for each one you have read
    MongoDB
    db.getSiblingDB('admin').aggregate([
      { $currentOp: { allUsers: true, idleSessions: true } },
      { $match: { transaction: { $exists: true } } },
      { $project: { appName: 1, client: 1, 'transaction.timeOpenMicros': 1 } }])
    // MongoDB aborts transactions older than transactionLifetimeLimitSeconds (60 s) by itself

    Look for: Connections fall right away. If they come back within minutes, the app has a code path that never commits: get the app team on the call.

    Undo: Nothing to undo. The app reconnects.

  2. 5Fix it at the source: roll back, scale down, or shrink the poolLow-risk changeTime box: 10 minutes

    The database is fine; it is being asked for more connections than it has. The app team owns this lever, so this is a call, not a command.

    In the shell
    # with the app team, the fastest of:
    kubectl rollout undo deployment/<app> -n <namespace>     # the deploy that caused it
    kubectl scale deployment/<app> --replicas=<before> -n <namespace>
    # or lower the pool size in the app's config and restart it

    Look for: Connections fall below 80 percent within a few minutes of the change.

    Undo: Roll forward again once the pool math fits.

  3. 6Fence off the user that is flooding youLow-risk changeTime box: 5 minutes

    A script or report should never take the connections your customers need. Stop new ones, then end the existing ones.

    PostgreSQL
    ALTER ROLE report_user CONNECTION LIMIT 0;   -- no new sessions for this role
    SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE usename = 'report_user';
    MySQL
    ALTER USER 'report_user'@'%' ACCOUNT LOCK;
    -- then KILL each of its connections (see step 2 for the list)
    MongoDB
    // no server-side per-user connection cap: stop the client, or
    db.getSiblingDB('admin').revokeRolesFromUser('report_user', [{ role: 'read', db: 'app' }])

    Look for: Its connections drop to zero and stay there.

    Undo: PostgreSQL: ALTER ROLE report_user CONNECTION LIMIT -1; MySQL: ALTER USER 'report_user'@'%' ACCOUNT UNLOCK;

  4. 7Last resort: raise the limitRisky: a human decides

    Only if the load is real and the server has memory for it. On PostgreSQL this needs a restart, which drops every connection: that is a bigger outage than the one you have.

    PostgreSQL
    -- PgBouncer in transaction mode in front of PostgreSQL is the usual answer.
    -- max_connections only changes with a restart:
    ALTER SYSTEM SET max_connections = 400;   -- then a planned restart
    MySQL
    -- takes effect at once, and survives a restart
    SET PERSIST max_connections = 800;
    -- ProxySQL multiplexes many app connections onto fewer backends
    MongoDB
    // raise net.maxIncomingConnections in mongod.conf (restart), or
    // connect through mongos, which pools connections to the shards

    Look for: Do the memory math first. On PostgreSQL, a pooler in front (PgBouncer) is the real fix, and it can be added without a restart.

    Undo: Set the old value back (PostgreSQL: another restart).

Confirm it is fixed
  1. 8Confirm it heldOnly reads

    Connections under 80 percent and the app's pool wait time back to normal, for 15 minutes.

    PostgreSQL
    SELECT count(*) AS in_use,
           current_setting('max_connections') AS max,
           current_setting('superuser_reserved_connections') AS reserved_for_admins
    FROM pg_stat_activity WHERE backend_type = 'client backend';
    MySQL
    SHOW VARIABLES LIKE 'max_connections';
    SHOW GLOBAL STATUS WHERE Variable_name IN
      ('Threads_connected', 'Threads_running', 'Max_used_connections',
       'Connection_errors_max_connections');
    MongoDB
    db.serverStatus().connections   // current, available, totalCreated

    Look for: Also check the app's error rate, not just the database: that is what users feel.

What changes on your platform
On RDS or Aurora
  • There is no shell on the host. Use Performance Insights (top SQL, waits, hosts and users) and the DatabaseConnections metric in CloudWatch.
  • PostgreSQL: rds_superuser can end other users' sessions with pg_terminate_backend. MySQL: KILL is not allowed for other users; use the RDS procedures.
    CALL mysql.rds_kill(<thread id>);         -- end the connection
    CALL mysql.rds_kill_query(<thread id>);   -- cancel the statement
  • max_connections comes from the parameter group, often a formula on instance memory. Changing it on PostgreSQL needs a reboot. RDS Proxy is the managed pooler, and it also hides failovers from the app.
On Kubernetes
  • Pods times pool size is the math, and a HorizontalPodAutoscaler can double pods in a minute. Check it first.
    kubectl get hpa -A
    kubectl get pods -l app=<app> -n <ns> --no-headers | wc -l
  • Get into the database through its pod. With an operator, use its tooling.
    kubectl exec -it <db-pod> -n <ns> -- psql -U postgres
    kubectl cnpg psql <cluster> -n <ns>     # CloudNativePG plugin
  • Change max_connections in the operator's custom resource, not in the config file inside the pod: the operator puts its own version back.
Escalate, or get a second DBA, when
  • Most connections are active: this is a slowness incident, bring in whoever owns the slow query.
  • Anyone proposes restarting the database, or raising max_connections on PostgreSQL.
  • It comes back after every fix: the app is leaking connections, and the app team has to be on the call.

Get the application team on a call

When
  • The connections belong to one app, and the fix is its pool, its replica count or a rollback.
  • Sessions sit idle in a transaction: that is a code path that never commits.
Ask them
  • How many instances do you run, and what is the pool size per instance? During a deploy, how many run at once?
  • Do you open a transaction and then call another service, or wait on a user, before committing?
  • Did anything change today: a deploy, autoscaling settings, a new service using the same database?
  • Do workers, cron jobs or Lambdas open their own connections?
What to suggest, and when it fits
Shrink the poolMost apps need far fewer connections than they ask for. A pool of 5 to 10 per instance is plenty for many web apps.
Put a pooler in frontMany instances or serverless functions: PgBouncer or RDS Proxy for PostgreSQL, ProxySQL for MySQL.
Keep transactions shortNever hold a transaction open across a network call. Commit, then call.
Set timeouts in the driverA connection timeout and a pool wait timeout, so a slow database fails fast instead of piling up.
Status update to post
Database <name>: connections are at the limit, so some requests fail. Cause: <app> is holding <n> connections after <change>. We are <action>. Next update <time>.

Done when: Connections stay under 80 percent for 15 minutes, the app shows no connection errors, and you know which app and which change caused it.

Don't
  • Restart the database to clear connections. Every client reconnects at once into the same storm, and the evidence is gone.
  • Raise max_connections on PostgreSQL in the middle of an incident. It needs a restart, and more processes make a slow server slower.

Postmortem: so it does not happen again

Prevent it
  • Write the pool math into the deploy checklist: instances times pool size, at peak and during a rolling deploy, stays under 70 percent of the limit.
  • idle_in_transaction_session_timeout (PostgreSQL) or a short wait_timeout (MySQL) for app users.
  • A pooler in front of PostgreSQL once there are more than a few app instances.
Catch it earlier
  • Alert at 80 percent of max_connections, not at 100.
  • Alert on any session idle in a transaction for more than 5 minutes.
  • A per-app connection count on the dashboard, so the owner is obvious.
Automate it
  • An agent can end sessions idle in a transaction past a threshold, post what it ended, and page if they come back.
  • A pre-deploy check that compares the new replica count times pool size with the database limit, and blocks the deploy if it does not fit.

The pooling decision: Connection management and pooling.

CPU at 100%The database CPU is pinned and everything is slower. Often no single query looks slow on its own.Open the playbookClose · 9 steps
You are here if
  • Database CPU above 90 percent for several minutes
  • Latency up across many endpoints at once
  • Load average well above the number of cores
  • Active sessions far above the number of cores

Start here. Find the one query fingerprint eating the CPU right now, and what changed to make it do that. Usually it is one fast query that suddenly runs much more often, or one that lost its index.

Likely causes, most common first
  1. A query that runs thousands of times a second lost its index or changed plan.
  2. A new feature added a query without an index: each call scans.
  3. Many short queries with high per-call overhead, such as one query per row in a loop.
  4. Sorting or hashing large results in memory.
Confirm and scope
  1. 1Make sure it is the database processOnly reads

    A backup, an agent or another service on the same host looks the same from the app.

    In the shell
    top -b -n 1 -o %CPU | head -15      # which process is using the CPU
    uptime                                 # load average against the number of cores

    Look for: postgres, mysqld or mongod on top: carry on.

    • If something else is on top → Stop or move it. That is your fix.
Find the cause
  1. 2See which query fills the active sessionsOnly reads

    Active sessions compared with cores tells you how bad it is. Twice the core count means everything is queueing.

    PostgreSQL
    SELECT left(query, 100) AS query, count(*) AS running,
           max(now() - query_start) AS longest
    FROM pg_stat_activity
    WHERE state = 'active' AND pid <> pg_backend_pid()
    GROUP BY 1 ORDER BY 2 DESC LIMIT 15;
    MySQL
    SELECT LEFT(info, 100) AS query, count(*) AS running, max(time) AS longest_s
    FROM information_schema.processlist
    WHERE command = 'Query' AND id <> CONNECTION_ID()
    GROUP BY 1 ORDER BY 2 DESC LIMIT 15;
    MongoDB
    db.currentOp({ active: true }).inprog
      .filter(o => o.op !== 'none')
      .forEach(o => print(o.opid, o.secs_running + 's', o.ns, o.planSummary))

    Look for: One fingerprint with dozens of copies is the usual picture.

  2. 3Rank by time used in the last minuteOnly reads

    Totals since the last reset hide what changed today. The difference over one minute shows what is burning CPU now.

    PostgreSQL
    -- what used the CPU in the last minute, not since the last reset
    DROP TABLE IF EXISTS snap;
    CREATE TEMP TABLE snap AS
      SELECT userid, dbid, queryid, calls, total_exec_time FROM pg_stat_statements;
    SELECT pg_sleep(60);
    SELECT s.calls - p.calls AS calls_last_min,
           round((s.total_exec_time - p.total_exec_time)::numeric) AS ms_last_min,
           left(s.query, 80) AS query
    FROM pg_stat_statements s JOIN snap p USING (userid, dbid, queryid)
    ORDER BY 2 DESC LIMIT 10;
    MySQL
    -- what used the time in the last minute
    DROP TEMPORARY TABLE IF EXISTS snap;
    CREATE TEMPORARY TABLE snap AS
      SELECT schema_name, digest, count_star, sum_timer_wait
      FROM performance_schema.events_statements_summary_by_digest;
    DO SLEEP(60);
    SELECT d.count_star - s.count_star AS calls_last_min,
           ROUND((d.sum_timer_wait - s.sum_timer_wait) / 1e9) AS ms_last_min,
           LEFT(d.digest_text, 80) AS query
    FROM performance_schema.events_statements_summary_by_digest d
    JOIN snap s ON s.digest = d.digest AND s.schema_name <=> d.schema_name
    ORDER BY 2 DESC LIMIT 10;
    MongoDB
    // if profiling is off, turn it on first (changes a setting):
    // db.setProfilingLevel(1, { slowms: 50 })
    db.system.profile.find({}, { ns: 1, millis: 1, planSummary: 1, docsExamined: 1, nreturned: 1 })
      .sort({ millis: -1 }).limit(10)

    Look for: The top line is usually more than half of all the time. Note its calls per minute: compare with last week if your monitoring keeps it.

    • If its calls per minute jumped → A deploy, a retry loop or a traffic spike. Ask what changed, and get the app team on the call.
    • If same calls, each one slower → step 4: Read the plan of that query
  3. 4Read the plan of that queryOnly reads

    A scan where there used to be an index lookup turns a cheap query into an expensive one.

    PostgreSQL
    -- ANALYZE runs the query. For an UPDATE or DELETE, wrap it:
    BEGIN;
    EXPLAIN (ANALYZE, BUFFERS) <the query>;
    ROLLBACK;
    MySQL
    EXPLAIN ANALYZE <the query>;   -- runs it (MySQL 8.0.18 and later)
    EXPLAIN FORMAT=TREE <the query>;   -- the plan only
    MongoDB
    db.orders.find({ customer_id: 42 }).explain('executionStats')
    // compare totalDocsExamined with nReturned

    Look for: Seq Scan, type ALL or COLLSCAN on a big table, or rows examined far above rows returned.

Stop the bleeding, least risky first
  1. 5If it started with a deploy: roll it backLow-risk changeTime box: 10 minutes

    The fastest and safest fix when the timing lines up. You can fix the query properly tomorrow.

    In the shell
    kubectl rollout undo deployment/<app> -n <namespace>
    # or turn off the feature flag that shipped the new query

    Look for: CPU falls within a couple of minutes of the rollback finishing.

    Undo: Roll forward once the query is fixed.

  2. 6Cancel the runaway queries and turn off their sourceLow-risk changeTime box: 5 minutes

    Cancelling buys minutes. If the app retries, they come straight back, so stop the source too: the job, the endpoint, the flag.

    PostgreSQL
    SELECT pg_cancel_backend(pid)      -- cancels the query, keeps the session
    FROM pg_stat_activity
    WHERE state = 'active' AND query LIKE '%<part of the query>%'
      AND now() - query_start > interval '1 minute';
    MySQL
    KILL QUERY <thread id>;   -- cancels the statement, keeps the connection
    MongoDB
    db.killOp(<opid>)

    Look for: CPU drops. If it climbs back within a minute, the source is still running.

    Undo: Nothing to undo. The query can be run again later.

  3. 7Add the missing index, onlineRisky: a human decides

    The real fix, if the table is not huge. On a busy host, the build itself adds load: check the table size and expect it to take a while.

    PostgreSQL
    CREATE INDEX CONCURRENTLY orders_customer_idx ON orders (customer_id);
    -- if it fails it leaves an INVALID index: drop it and run it again
    MySQL
    ALTER TABLE orders ADD INDEX orders_customer_idx (customer_id),
      ALGORITHM = INPLACE, LOCK = NONE;
    MongoDB
    db.orders.createIndex({ customer_id: 1 })   // holds an exclusive lock only at the start and the end

    Look for: The plan uses it, and the query's time per call falls.

    Undo: PostgreSQL: DROP INDEX CONCURRENTLY orders_customer_idx; MySQL: ALTER TABLE orders DROP INDEX orders_customer_idx; MongoDB: db.orders.dropIndex("orders_customer_idx")

  4. 8Last resort: a bigger instance or more read replicasRisky: a human decides

    Costs money and, on most managed services, a failover. Worth it only if the load is real and nothing above helps.

    In the shell
    # RDS: modify the instance class (Multi-AZ: a failover of a minute or two)
    aws rds modify-db-instance --db-instance-identifier <id> --db-instance-class <bigger> --apply-immediately

    Look for: Plan it with the app owner: they will see errors during the failover.

Confirm it is fixed
  1. 9Confirm it heldOnly reads

    CPU near its normal level for 15 minutes and the query's time per call back to normal.

    PostgreSQL
    -- what used the CPU in the last minute, not since the last reset
    DROP TABLE IF EXISTS snap;
    CREATE TEMP TABLE snap AS
      SELECT userid, dbid, queryid, calls, total_exec_time FROM pg_stat_statements;
    SELECT pg_sleep(60);
    SELECT s.calls - p.calls AS calls_last_min,
           round((s.total_exec_time - p.total_exec_time)::numeric) AS ms_last_min,
           left(s.query, 80) AS query
    FROM pg_stat_statements s JOIN snap p USING (userid, dbid, queryid)
    ORDER BY 2 DESC LIMIT 10;
    MySQL
    -- what used the time in the last minute
    DROP TEMPORARY TABLE IF EXISTS snap;
    CREATE TEMPORARY TABLE snap AS
      SELECT schema_name, digest, count_star, sum_timer_wait
      FROM performance_schema.events_statements_summary_by_digest;
    DO SLEEP(60);
    SELECT d.count_star - s.count_star AS calls_last_min,
           ROUND((d.sum_timer_wait - s.sum_timer_wait) / 1e9) AS ms_last_min,
           LEFT(d.digest_text, 80) AS query
    FROM performance_schema.events_statements_summary_by_digest d
    JOIN snap s ON s.digest = d.digest AND s.schema_name <=> d.schema_name
    ORDER BY 2 DESC LIMIT 10;
    MongoDB
    // if profiling is off, turn it on first (changes a setting):
    // db.setProfilingLevel(1, { slowms: 50 })
    db.system.profile.find({}, { ns: 1, millis: 1, planSummary: 1, docsExamined: 1, nreturned: 1 })
      .sort({ millis: -1 }).limit(10)

    Look for: Keep watching through the next traffic peak.

What changes on your platform
On RDS or Aurora
  • Performance Insights is the fastest view: database load by wait and by SQL, against the vCPU line. Load above the vCPU line means queueing.
  • On burstable classes (db.t3, db.t4g) in Standard mode, CPUCreditBalance at zero throttles the instance to baseline. The default is Unlimited mode, where a zero balance instead means surplus-credit charges. Check the credit specification and CPUSurplusCreditsCharged, not just CPUCreditBalance. It looks like a CPU incident and is a billing setting.
    aws cloudwatch get-metric-statistics --namespace AWS/RDS --metric-name CPUCreditBalance \
      --dimensions Name=DBInstanceIdentifier,Value=<id> --start-time <iso> --end-time <iso> --period 300 --statistics Minimum
  • Scaling the instance class on Multi-AZ fails over to the standby first: one to two minutes of errors. Plan it with the app owner.
On Kubernetes
  • Check the CPU limit on the database container. A limit causes throttling (CFS) long before the node is busy: latency rises while CPU looks under 100 percent.
    kubectl top pod <db-pod> -n <ns>
    kubectl get pod <db-pod> -n <ns> -o jsonpath='{.spec.containers[*].resources}'
  • Many teams run databases with a CPU request but no CPU limit for exactly this reason.
Escalate, or get a second DBA, when
  • CPU stays above 90 percent for 15 minutes after you acted.
  • The fix needs an index build on a large table, a rollback, or an instance resize.
  • The top query belongs to a team that is not on the call yet.

Get the application team on a call

When
  • One query fingerprint uses most of the CPU, and it comes from an application.
  • Its calls per minute jumped: something in the app changed, or it is retrying in a loop.
Ask them
  • What does this query serve: a page users wait on, an API, a background job? How often does it run, and how often should it?
  • Did a deploy or a feature flag change it today?
  • Does the result change often, or could it be the same for seconds or minutes?
  • Is it run once per item in a loop (the N+1 pattern)?
  • Does it need to be exact and current, or could it read from a replica?
What to suggest, and when it fits
Add an indexThe query is right but scans. A composite index that matches its WHERE and ORDER BY usually fixes it for good.
Rewrite the queryIt fetches more than it uses, has a function on the indexed column, or uses OFFSET paging on deep pages. Fetch less, keep the column bare, use keyset paging.
Cache the resultRead far more often than it changes, and a few seconds stale is fine: product pages, settings, counts. Redis in front, with a TTL.
Batch itOne query per item in a loop: fetch them all with one IN list or a join.
Move it off the primaryReports and exports go to a replica or a warehouse, not the primary that serves customers.
Rate limit or queue itA job or endpoint that can flood the database: cap its concurrency.
Status update to post
Database <name>: CPU is saturated, so most requests are slow. Cause: <query> from <app>, <why>. We are <action>. Next update <time>.

Done when: CPU is back to normal through a traffic peak, and you know which query, which change and which fix.

Don't
  • Buy a bigger instance before you know the query. A scan at twice the traffic eats the new CPU too.
  • Keep cancelling the same query every few minutes. Stop its source.

Postmortem: so it does not happen again

Prevent it
  • Every new query gets an EXPLAIN on production-sized data in code review.
  • Reports and batch jobs run on replicas, with their own users and limits.
  • Per-user statement_timeout so one runaway query cannot hold the CPU for an hour.
Catch it earlier
  • Alert on CPU above 80 percent for 10 minutes.
  • Track the top queries by total time every day, and alert when a new one enters the top five.
  • Alert on calls per minute of the top fingerprints jumping.
Automate it
  • An agent can take the one-minute snapshot, name the top fingerprint, its owner app and its plan, and post it in the channel within a minute of the alert.
  • Run the plans of new queries in CI against a copy of production statistics, and flag scans on big tables before they ship.

How plans go wrong: Queries that look fine and are not, and paste one into the query coach.

The disk is filling upFree space is falling faster than the data is growing, or an alert fired at 85%.Open the playbookClose · 8 steps
You are here if
  • Disk usage alert, or free space falling quickly
  • "No space left on device", "could not write to file", errno 28 in the database log
  • PostgreSQL PANIC on pg_wal: the server stops

Start here. Work out the time until the disk is full. Under an hour, the first move is to grow the volume, then look for the cause. Never delete database files by hand.

Likely causes, most common first
  1. Log files are being kept: a PostgreSQL replication slot whose reader is gone, MySQL binlogs kept for 30 days by default, a MongoDB oplog sized large.
  2. Dead rows or old versions are not being cleaned up, so tables grow without growing in rows.
  3. A large temporary sort or index build.
  4. Real growth that nobody projected.
Confirm and scope
  1. 1How long until full, and which directory is growingOnly reads

    Time to full decides whether you investigate first or grow the volume first.

    PostgreSQL
    SHOW data_directory;
    -- in the shell: du -sh $PGDATA/base $PGDATA/pg_wal $PGDATA/pg_replslot $PGDATA/log
    MySQL
    SELECT @@datadir, @@log_bin_basename, @@innodb_temp_data_file_path;
    MongoDB
    const o = db.adminCommand({ getCmdLineOpts: 1 }).parsed;
    print((o.storage && o.storage.dbPath) || '/data/db (the default)')
    In the shell
    df -h                                   # run it twice, 10 minutes apart
    du -sh /path/to/data/dir/* | sort -h | tail -15

    Look for: Run df twice, ten minutes apart, and divide.

Find the cause
  1. 2Find what is growing: log, data, temp or server logsOnly reads

    Each has a different fix. WAL, binlogs and server logs grow fastest.

    PostgreSQL
    SELECT slot_name, slot_type, active,
           pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn)) AS wal_kept
    FROM pg_replication_slots ORDER BY restart_lsn;
    -- WAL archiving failing also keeps WAL
    SELECT archived_count, failed_count, last_failed_wal, last_failed_time
    FROM pg_stat_archiver;
    MySQL
    SHOW BINARY LOGS;
    SELECT @@binlog_expire_logs_seconds / 86400 AS days_kept;
    MongoDB
    rs.printReplicationInfo()   // the oplog has a fixed size, so it is rarely the cause
    db.adminCommand({ getCmdLineOpts: 1 }).parsed.systemLog   // where the mongod log lives; unrotated logs grow

    Look for: Read the result against the directory sizes from step 1.

  2. 3Check whether someone left verbose logging onOnly reads

    Statement logging left on after a debug session can write gigabytes an hour.

    PostgreSQL
    SELECT name, setting FROM pg_settings
    WHERE name IN ('log_min_duration_statement', 'log_statement', 'log_connections', 'log_disconnections');
    MySQL
    SHOW VARIABLES WHERE Variable_name IN ('general_log', 'slow_query_log', 'long_query_time', 'log_output');
    MongoDB
    db.getProfilingStatus()
    db.adminCommand({ getParameter: 1, logLevel: 1 })

    Look for: log_min_duration_statement = 0, log_statement = all, or the MySQL general log ON: turn it off and delete old log files. Safe.

Stop the bleeding, least risky first
  1. 4Grow the volume firstLow-risk changeTime box: 15 minutes

    On cloud volumes this is online and takes minutes. It buys the time to find the cause calmly.

    In the shell
    # grow the volume: on AWS, modify the EBS volume, then
    sudo growpart /dev/nvme1n1 1   # if it has a partition
    sudo xfs_growfs /data          # or: sudo resize2fs /dev/nvme1n1p1

    Look for: Free space jumps. On RDS: modify the allocated storage; you cannot change it again for six hours, so add enough.

    Undo: Volumes cannot shrink. That is fine.

  2. 5Drop the replication slot nobody readsRisky: a human decides

    A CDC tool or replica that died long ago keeps every WAL file since. Find its owner first: dropping the slot means that consumer needs a full resync.

    PostgreSQL
    -- only after you confirm nothing will use this slot again:
    SELECT pg_drop_replication_slot('old_slot');   -- its reader needs a full resync
    -- fix archive_command if step 2 showed failures; WAL is then removed by itself

    Look for: pg_wal shrinks at the next checkpoint.

    Undo: None. The consumer has to be rebuilt from a fresh snapshot.

  3. 6Purge binlogs every replica has already readLow-risk change

    Check every replica first: purging a binlog a replica still needs breaks that replica.

    MySQL
    -- check every replica has read past this point first (SHOW REPLICA STATUS)
    PURGE BINARY LOGS BEFORE NOW() - INTERVAL 3 DAY;
    SET PERSIST binlog_expire_logs_seconds = 604800;   -- 7 days

    Look for: Free space rises at once.

    Undo: None. Keep a few days of binlogs for point-in-time recovery.

  4. 7Cancel the query writing huge temporary filesLow-risk change

    A sort or hash spilling tens of GB is usually a bad query, not a real need.

    PostgreSQL
    SELECT datname, temp_files, pg_size_pretty(temp_bytes) AS temp
    FROM pg_stat_database ORDER BY temp_bytes DESC;
    SELECT pid, now() - query_start AS running, left(query, 80)
    FROM pg_stat_activity WHERE state = 'active' ORDER BY query_start LIMIT 5;
    MySQL
    -- the session temporary tablespace and ibtmp1 (ibtmp1 only shrinks at restart)
    SELECT * FROM information_schema.innodb_session_temp_tablespaces;
    MongoDB
    // aggregations with allowDiskUse spill under the dbPath, in _tmp
    db.currentOp({ active: true, secs_running: { $gte: 60 } })

    Look for: Cancel it (see CPU at 100%, step 6), then look at its plan.

Confirm it is fixed
  1. 8Confirm free space is stableOnly reads

    Flat or rising for 30 minutes, with the cause gone, not just pushed back.

    In the shell
    df -h                                   # run it twice, 10 minutes apart
    du -sh /path/to/data/dir/* | sort -h | tail -15

    Look for: Estimate when it will fill again at normal growth, and put that date in the ticket.

What changes on your platform
On RDS or Aurora
  • Watch FreeStorageSpace. At zero the instance goes to storage-full and stops writes. Turn on storage autoscaling with a maximum; after any storage change you must wait six hours for the next one.
  • PostgreSQL: TransactionLogsDiskUsage and OldestReplicationSlotLag show WAL kept by slots. MySQL: binlog retention is a procedure, not a variable.
    CALL mysql.rds_show_configuration;
    CALL mysql.rds_set_configuration('binlog retention hours', 24);
  • Aurora data storage grows by itself, but local storage for temp files does not: watch FreeLocalStorage. A big sort can fill it and fail queries.
On Kubernetes
  • The volume is a PersistentVolumeClaim. Grow it through the operator's resource, or patch the PVC if the storage class allows expansion.
    kubectl get pvc -n <ns>
    kubectl get storageclass <class> -o jsonpath='{.allowVolumeExpansion}'
    kubectl patch pvc <pvc> -n <ns> -p '{"spec":{"resources":{"requests":{"storage":"200Gi"}}}}'
  • Never delete a PVC to free space. With most storage classes the reclaim policy deletes the data with it.
Escalate, or get a second DBA, when
  • Less than 30 minutes to full and you cannot grow the volume.
  • The server has already stopped (PostgreSQL PANIC on WAL): this is now a recovery, bring a second DBA.
  • Dropping a slot or purging logs would break a replica or a CDC pipeline someone else owns.

Get the application team on a call

When
  • A CDC connector, replica or data pipeline owned by another team holds a slot or old binlogs.
  • An app or job is writing much more data than planned.
Ask them
  • Is your connector or replica still running? When did it last read? Can it be rebuilt from a snapshot if we drop its slot?
  • What is writing this data, how much per day, and how long must it be kept?
  • Can old rows be deleted or moved out, and on what schedule?
What to suggest, and when it fits
Monitor the consumerA CDC connector that stops should page its owners, before the database disk fills.
Partition by timeData with a retention period: drop old partitions instead of running big deletes.
Move cold data outArchive old rows to object storage or a warehouse.
Set a slot size limitPostgreSQL max_slot_wal_keep_size caps how much WAL a dead slot can keep.
Status update to post
Database <name>: disk is <n>% full and growing <rate>. Cause: <what>. We have <grown the volume / are freeing space>. Risk of writes stopping at <time>. Next update <time>.

Done when: Free space is stable, the cause is fixed, and the projected full date is months away.

Don't
  • rm files in pg_wal, binlogs, redo logs or MongoDB data files. The database will not start, or a replica is lost.
  • Drop a replication slot before you know who reads it.

Postmortem: so it does not happen again

Prevent it
  • max_slot_wal_keep_size on PostgreSQL, so a dead slot cannot fill the disk.
  • binlog_expire_logs_seconds set to what point-in-time recovery needs, not 30 days by default.
  • Log rotation with a size cap, and verbose logging turned off with a reminder after debugging.
Catch it earlier
  • Alert on time to full (growth rate), not only on percent used.
  • Alert when a replication slot is inactive or holds more than a few GB.
  • Alert on WAL archiving failures.
Automate it
  • An agent can compute time to full every few minutes and grow a cloud volume by a fixed step when it drops under a threshold, with a human notified.
  • A weekly report of the largest tables and their growth, with a projected full date.

The on-call drill for this one: On call tonight, incident 1. And why the bill is huge.

A replica is far behindReads from replicas return old data, or the lag alert fired. A failover now would lose more, or take longer.Open the playbookClose · 8 steps
You are here if
  • Replica lag alert, in seconds or bytes
  • Users see old data after saving: reads go to a replica
  • A failover would lose more than you accept

Start here. Decide two things fast: are users affected, because reads go to that replica, and is your failover target safe. Then find whether the replica is not receiving changes or not applying them.

Likely causes, most common first
  1. One large transaction on the primary: a big DELETE or UPDATE replays as one long unit.
  2. The replica applies changes with fewer threads than the primary writes them.
  3. Long queries on the replica block or delay replay.
  4. The replica has a slower disk, or is busy with backups or reports.
Confirm and scope
  1. 1How far behind, and which replicasOnly reads

    Seconds tell you how stale reads are. Bytes tell you what a failover now would lose or have to replay.

    PostgreSQL
    -- on the primary
    SELECT application_name, client_addr, state,
           pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn)) AS behind,
           write_lag, flush_lag, replay_lag
    FROM pg_stat_replication;
    MySQL
    SHOW REPLICA STATUS\G
    -- Seconds_Behind_Source, Replica_IO_Running, Replica_SQL_Running,
    -- Last_IO_Error, Last_SQL_Error
    MongoDB
    rs.printSecondaryReplicationInfo()

    Look for: One replica behind: a problem on that replica. All of them: something on the primary, usually one huge write.

Find the cause
  1. 2Receiving or applying?Only reads

    The fix is in a different place for each.

    PostgreSQL
    -- on the replica
    SELECT pg_last_wal_receive_lsn() AS received,
           pg_last_wal_replay_lsn()  AS applied,
           pg_is_wal_replay_paused()  AS paused,
           now() - pg_last_xact_replay_timestamp() AS behind;
    SELECT status, sender_host, last_msg_receipt_time FROM pg_stat_wal_receiver;
    MySQL
    SHOW REPLICA STATUS\G
    -- Retrieved_Gtid_Set (received) against Executed_Gtid_Set (applied)
    SELECT * FROM performance_schema.replication_applier_status_by_worker\G
    MongoDB
    rs.status().members.map(m => [m.name, m.stateStr, m.optimeDate, m.syncSourceHost])

    Look for: Compare received with applied.

    • If received is far ahead of applied → step 3: What is slowing the apply
    • If received itself is far behind the primary → Network, or the primary is saturated: check the primary's disk and CPU.
  2. 3What is slowing the applyOnly reads

    One giant transaction on the primary, or a long query on the replica, explains most of it.

    PostgreSQL
    -- on the replica: queries that delay or conflict with replay
    SELECT pid, now() - query_start AS running, left(query, 80)
    FROM pg_stat_activity WHERE state = 'active' ORDER BY query_start LIMIT 10;
    SELECT * FROM pg_stat_database_conflicts WHERE datname = current_database();
    SHOW max_standby_streaming_delay;
    MySQL
    SHOW VARIABLES LIKE 'replica_parallel%';
    SHOW PROCESSLIST;   -- the applier threads and their state
    MongoDB
    db.serverStatus().metrics.repl.buffer
    // and CPU and disk on the secondary: an overloaded secondary falls behind

    Look for: A long report on a PostgreSQL replica can hold replay back. A big DELETE on the primary replays as one unit.

  3. 4If replication stopped: read the errorOnly reads

    Do not skip transactions to get it going. The replica would then be wrong in a way nobody can see.

    PostgreSQL
    -- in the replica's log: the error, often a missing WAL file
    -- (the primary removed it before the replica read it)
    MySQL
    SHOW REPLICA STATUS\G   -- Last_SQL_Error, Last_IO_Error
    SELECT * FROM performance_schema.replication_applier_status_by_worker\G
    MongoDB
    rs.status()   // look for a member in RECOVERING or with an error message

    Look for: A WAL or binlog the primary no longer has means the replica cannot catch up: rebuild it.

Stop the bleeding, least risky first
  1. 5Take the lagging replica out of the read poolLow-risk changeTime box: 5 minutes

    This fixes what users see in a minute, without touching replication.

    MySQL
    KILL QUERY <thread id>;   -- the long query on the replica
    -- remove it from the ProxySQL reader hostgroup
    MongoDB
    // readPreference for that app: primaryPreferred, until the secondary catches up

    Look for: Stale-read complaints stop. Make sure the others can carry the reads.

    Undo: Put it back once lag is under your threshold.

  2. 6Pause the big write job on the primaryLow-risk changeTime box: 10 minutes

    One DELETE of 50 million rows becomes hours of lag. Stopping it, and running it in chunks later, ends the lag growth at once.

    In the shell
    # with the job's owner: stop the job. Then, for later:
    # delete in chunks of a few thousand rows, with a short pause between chunks

    Look for: Lag stops growing, then falls.

    Undo: Restart the job in chunks.

  3. 7Rebuild the replicaLow-risk change

    Sometimes a fresh copy is faster than waiting. Out of the read pool while it builds.

    PostgreSQL
    pg_basebackup -h <primary> -D /new/data/dir -X stream -P -R
    MySQL
    CLONE INSTANCE FROM 'clone_user'@'primary':3306 IDENTIFIED BY '...';   -- the clone plugin
    MongoDB
    // stop the secondary, empty its dbPath, start it: it runs an initial sync

    Look for: Time it. That number belongs in your recovery plan.

Confirm it is fixed
  1. 8Confirm it caught upOnly reads

    Lag under your threshold for 15 minutes, then back into the read pool.

    PostgreSQL
    -- on the primary
    SELECT application_name, client_addr, state,
           pg_size_pretty(pg_wal_lsn_diff(pg_current_wal_lsn(), replay_lsn)) AS behind,
           write_lag, flush_lag, replay_lag
    FROM pg_stat_replication;
    MySQL
    SHOW REPLICA STATUS\G
    -- Seconds_Behind_Source, Replica_IO_Running, Replica_SQL_Running,
    -- Last_IO_Error, Last_SQL_Error
    MongoDB
    rs.printSecondaryReplicationInfo()

    Look for: Also confirm your failover target is current again.

What changes on your platform
On RDS or Aurora
  • ReplicaLag in CloudWatch for RDS read replicas, AuroraReplicaLag for Aurora. Aurora replicas share storage, so their lag is usually milliseconds: seconds of lag on Aurora means the replica is overloaded or restarting.
  • MySQL on RDS: replication errors are skipped with a procedure. Do not use it to make an error go away; rebuild the replica instead.
    CALL mysql.rds_skip_repl_error;   -- the same risk as sql_replica_skip_counter
On Kubernetes
  • With an operator, check its view of the replicas, then the database's.
    kubectl cnpg status <cluster> -n <ns>          # CloudNativePG
    kubectl exec <pod> -n <ns> -- patronictl list   # Zalando and Crunchy run Patroni
  • A replica on a node with a slow or shared disk lags. Check which node and which storage class it landed on.
    kubectl get pod -o wide -n <ns>
Escalate, or get a second DBA, when
  • The primary is unhealthy at the same time: a failover decision now includes how much data you accept losing. That is the service owner's call, not yours alone.
  • Replication broke with an error you do not recognise.
  • Lag keeps growing after you paused the obvious writer.

Get the application team on a call

When
  • A batch job, migration or backfill is the writer.
  • An app reads its own writes from a replica and users see stale data.
Ask them
  • What is this job doing, how many rows, and does it need to finish now?
  • Which reads go to replicas? Which of them must see a write the user just made?
  • How stale can each read be: a second, a minute?
What to suggest, and when it fits
Chunk big writesBatches of a few thousand rows with a pause, so replicas keep up.
Read your own writes from the primaryFor a few seconds after a user writes, send that user's reads to the primary.
Lag-aware routingThe proxy or driver stops sending reads to a replica that is more than N seconds behind.
Run heavy jobs off-peakBackfills and purges at night, with a throttle.
Status update to post
Database <name>: replica <r> is <n> behind, so <reads may be stale / failover protection is reduced>. Cause: <what>. We are <action>. Next update <time>.

Done when: Every replica is under the lag threshold, back in the read pool, and the failover target is current.

Don't
  • Fail over to a lagging replica without the owner agreeing to lose what it has not received.
  • Skip a failed transaction on MySQL (sql_replica_skip_counter) to make the error go away.

Postmortem: so it does not happen again

Prevent it
  • Big writes in chunks, enforced in code review for backfills and purges.
  • Parallel apply on MySQL replicas (replica_parallel_workers).
  • Reports run on a replica that is not the failover target.
Catch it earlier
  • Alert on lag in seconds and bytes, per replica.
  • Alert on replication stopped, separately from lag.
  • Show lag next to the write rate of the primary on one dashboard.
Automate it
  • An agent can take a replica out of the read pool when lag passes a threshold and put it back when it recovers.
  • A guard that pauses a batch job when replica lag passes a threshold.

The drill: incident 3. Side by side: a replica falls behind.

Queries waiting on locks, or timing outRequests hang, then fail with lock wait timeouts or deadlock errors. CPU may be low: things are waiting, not working.Open the playbookClose · 8 steps
You are here if
  • Requests hang, then fail with lock wait timeout or deadlock errors
  • Low CPU but high latency: things are waiting, not working
  • Often right after a migration starts

Start here. Find the one session at the front of the queue. In real outages it is usually a schema migration waiting behind a long transaction, with everything else queued behind the migration.

Likely causes, most common first
  1. One transaction holds a row or table lock and is not finishing: a slow job, or an app that opened a transaction and went off to call another service.
  2. A schema change waiting for a lock, with everything else queued behind it.
  3. Two code paths lock the same rows in different orders: deadlocks.
  4. Hot rows: many sessions updating one counter or one inventory row.
Confirm and scope
  1. 1Confirm sessions are waiting on locksOnly reads

    Lock waits look like a slow database with low CPU.

    PostgreSQL
    SELECT wait_event_type, wait_event, count(*)
    FROM pg_stat_activity WHERE state = 'active'
    GROUP BY 1, 2 ORDER BY 3 DESC;
    MySQL
    SELECT count(*) AS waiting FROM information_schema.innodb_trx
    WHERE trx_state = 'LOCK WAIT';
    SELECT state, count(*) FROM information_schema.processlist GROUP BY 1 ORDER BY 2 DESC;
    MongoDB
    db.currentOp({ waitingForLock: true }).inprog.length

    Look for: Most active sessions waiting on Lock, or in LOCK WAIT or "Waiting for table metadata lock".

Find the cause
  1. 2Find the blocker at the frontOnly reads

    A session that blocks others but is not blocked itself.

    PostgreSQL
    SELECT pid, usename, application_name, state,
           now() - xact_start AS transaction_age, left(query, 80) AS query
    FROM pg_stat_activity
    WHERE pid IN (SELECT unnest(pg_blocking_pids(pid)) FROM pg_stat_activity)
      AND cardinality(pg_blocking_pids(pid)) = 0;
    MySQL
    SELECT * FROM sys.innodb_lock_waits\G         -- row locks: blocking_pid, blocking_query
    SELECT * FROM sys.schema_table_lock_waits\G   -- metadata locks, such as an ALTER
    MongoDB
    db.getSiblingDB('admin').aggregate([
      { $currentOp: { allUsers: true, idleSessions: true } },
      { $match: { transaction: { $exists: true } } },
      { $sort: { 'transaction.timeOpenMicros': -1 } }, { $limit: 5 }])

    Look for: Note what it is and what it is doing.

  2. 3If waits keep coming back: find the hot rowOnly reads

    One counter or one stock row updated by everyone queues by design.

    PostgreSQL
    SELECT relation::regclass, mode, granted, count(*)
    FROM pg_locks WHERE relation IS NOT NULL
    GROUP BY 1, 2, 3 ORDER BY 4 DESC LIMIT 10;
    MySQL
    SELECT object_schema, object_name, lock_type, lock_mode, count(*)
    FROM performance_schema.data_locks GROUP BY 1, 2, 3, 4 ORDER BY 5 DESC LIMIT 10;
    MongoDB
    db.serverStatus().locks

    Look for: That is a design problem, not an on-call one: get the app team on the call.

Stop the bleeding, least risky first
  1. 4Cancel the migration firstLow-risk changeTime box: 2 minutes

    The migration is waiting for its lock, and everything queued behind it waits too. Cancelling it restores traffic at once and costs nothing: it can run again later with a lock timeout.

    PostgreSQL
    SELECT pid, pg_cancel_backend(pid) FROM pg_stat_activity
    WHERE query ~* '^\s*(alter|create index|drop|truncate)' AND wait_event_type = 'Lock';
    MySQL
    -- find the ALTER waiting for its metadata lock, then
    KILL QUERY <thread id of the ALTER>;
    MongoDB
    db.killOp(<opid of the index build or collMod>)

    Look for: The queue drains within seconds.

    Undo: Rerun the migration with a lock timeout (step 6).

  2. 5End the blocker that is idle in a transactionLow-risk changeTime box: 5 minutes

    It holds locks and does nothing. Ending it rolls its transaction back.

    PostgreSQL
    SELECT pg_cancel_backend(<pid>);      -- stops the running query
    SELECT pg_terminate_backend(<pid>);   -- ends the session and rolls back
    MySQL
    KILL QUERY <blocking_pid>;   -- or KILL <blocking_pid>; to end the connection
    -- sys.innodb_lock_waits also prints the statements: sql_kill_blocking_connection
    MongoDB
    db.killOp(<opid>)

    Look for: The queue drains. A big transaction takes time to roll back: do not end it twice.

    Undo: None. The app retries the work.

  3. 6Stop the long job, with its ownerRisky: a human decidesTime box: 10 minutes

    An active batch job might be halfway through something important. Ask before you kill it, but do not wait long.

    PostgreSQL
    SELECT pg_cancel_backend(<pid>);      -- stops the running query
    SELECT pg_terminate_backend(<pid>);   -- ends the session and rolls back
    MySQL
    KILL QUERY <blocking_pid>;   -- or KILL <blocking_pid>; to end the connection
    -- sys.innodb_lock_waits also prints the statements: sql_kill_blocking_connection
    MongoDB
    db.killOp(<opid>)

    Look for: Cancel it, then plan to rerun it in smaller transactions.

    Undo: The job reruns from its start or its last checkpoint.

  4. 7Rerun the migration safelyLow-risk change

    A short lock timeout means it gives up quickly instead of blocking everyone. Retry it in a loop until it gets the lock.

    PostgreSQL
    SET lock_timeout = '3s';
    ALTER TABLE orders ADD COLUMN note text;   -- retry until it gets the lock
    MySQL
    SET SESSION lock_wait_timeout = 5;
    ALTER TABLE orders ADD COLUMN note TEXT, ALGORITHM = INSTANT;
    MongoDB
    // MongoDB schema changes are index builds and collMod; check db.currentOp() for them

    Look for: It finishes in a moment or fails fast, and traffic is never stuck behind it.

Confirm it is fixed
  1. 8Confirm the queue is goneOnly reads

    No session waiting on a lock for more than a few seconds, for 15 minutes.

    PostgreSQL
    SELECT wait_event_type, wait_event, count(*)
    FROM pg_stat_activity WHERE state = 'active'
    GROUP BY 1, 2 ORDER BY 3 DESC;
    MySQL
    SELECT count(*) AS waiting FROM information_schema.innodb_trx
    WHERE trx_state = 'LOCK WAIT';
    SELECT state, count(*) FROM information_schema.processlist GROUP BY 1 ORDER BY 2 DESC;
    MongoDB
    db.currentOp({ waitingForLock: true }).inprog.length

    Look for: Check the app's error rate too.

What changes on your platform
On RDS or Aurora
  • Performance Insights shows lock waits as Lock:transactionid, Lock:tuple (PostgreSQL) or synch/... and innodb lock waits (MySQL), with the SQL behind them.
  • MySQL on RDS: end the blocker with the procedures, not KILL.
    CALL mysql.rds_kill(<blocking thread id>);
On Kubernetes
  • Migrations often run as a Job or an init container at deploy time. Find it and stop it before it retries.
    kubectl get jobs -n <ns>
    kubectl delete job <migration-job> -n <ns>
Escalate, or get a second DBA, when
  • The blocker is a job you do not own and cannot reach its owner.
  • Deadlocks every minute: a code path needs changing.
  • Waits return within minutes of every fix.

Get the application team on a call

When
  • A migration caused it.
  • The same hot rows keep blocking.
  • An app leaves transactions open.
Ask them
  • How do you run migrations: with a lock timeout and retries, at what time of day?
  • Which rows does everyone update at once: a counter, a balance, a stock level?
  • Do you call other services or wait on anything while a transaction is open?
  • Do two code paths update the same tables in a different order?
What to suggest, and when it fits
Lock timeout in every migrationlock_timeout (PostgreSQL) or lock_wait_timeout (MySQL) of a few seconds, with a retry loop, and an online schema change tool for big tables.
Split the hot rowSpread a counter over N rows and sum them, or append events and aggregate.
Shorter transactionsDo the slow work first, then open the transaction, write, commit.
Same lock order everywhereUpdate rows in the same order (by primary key) in every code path to end deadlocks.
Status update to post
Database <name>: queries are waiting on locks, so <feature> is timing out. Cause: <migration / transaction> from <app>. We are <action>. Next update <time>.

Done when: No lock waits for 15 minutes, and the migration or transaction that caused it has a safer plan.

Don't
  • Raise lock timeouts to make the errors go away. The waits only get longer.
  • Kill the waiting sessions one by one. End the blocker.

Postmortem: so it does not happen again

Prevent it
  • Every migration runs with a lock timeout and retries, reviewed like code.
  • idle_in_transaction_session_timeout for app users.
  • statement_timeout for app users, below the app's own request timeout.
Catch it earlier
  • Alert on the number of sessions waiting on locks, and on the age of the oldest transaction.
  • Log lock waits longer than a second (log_lock_waits in PostgreSQL).
Automate it
  • An agent can find the head blocker within seconds of the alert and post who it is, what it holds and how long it has run.
  • Auto-cancel a DDL that has waited for a lock longer than a few seconds while others queue behind it.

The drill: incident 2. The theory: Lost updates and write skew.

One query suddenly got slowA query that took milliseconds yesterday takes seconds today. The code did not change.Open the playbookClose · 7 steps
You are here if
  • One endpoint or job got slow while everything else is fine
  • One query's average time jumped, with no code change
  • Often after a big data load, a delete, a restore or a major upgrade

Start here. Prove it is one query, find the minute it changed, and get its real plan. Refreshing statistics is cheap and is often the whole fix.

Likely causes, most common first
  1. The planner picked a different plan: statistics went stale after a big load or delete.
  2. The data crossed a threshold, so a plan that was right for small tables is wrong now.
  3. A parameter value with very different selectivity: one customer with a million rows.
  4. An index was dropped, or became invalid after a failed build.
Confirm and scope
  1. 1Confirm it is one query, and when it changedOnly reads

    You want the fingerprint and the time its average jumped.

    PostgreSQL
    -- needs the pg_stat_statements extension
    SELECT calls, round(total_exec_time) AS total_ms,
           round(mean_exec_time::numeric, 2) AS mean_ms,
           rows, left(query, 80) AS query
    FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 10;
    MySQL
    SELECT query, exec_count, total_latency, avg_latency,
           rows_examined_avg, rows_sent_avg
    FROM sys.statement_analysis LIMIT 10;   -- sorted by total latency

    Look for: Compare its mean time with yesterday in your monitoring.

Find the cause
  1. 2Get the real plan with real valuesOnly reads

    Real timings and real row counts, not only the estimate.

    PostgreSQL
    BEGIN;
    EXPLAIN (ANALYZE, BUFFERS) <the slow query, with real values>;
    ROLLBACK;
    MySQL
    EXPLAIN ANALYZE <the slow query>;
    MongoDB
    db.orders.find({ customer_id: 42 }).sort({ created_at: -1 }).explain('executionStats')

    Look for: Compare the estimated rows with the actual rows at each step.

  2. 3Check the index exists and is validOnly reads

    A failed concurrent build leaves an index that exists but is never used.

    PostgreSQL
    SELECT indexrelid::regclass AS index, indisvalid, indisready
    FROM pg_index WHERE indrelid = 'orders'::regclass;
    MySQL
    SHOW INDEX FROM orders;
    SELECT * FROM sys.schema_unused_indexes WHERE object_name = 'orders';
    MongoDB
    db.orders.getIndexes()

    Look for: Invalid: drop and rebuild it concurrently. Missing: see CPU at 100%, step 7.

Stop the bleeding, least risky first
  1. 4Refresh the statisticsLow-risk changeTime box: 5 minutes

    A big load or delete changed the table under the planner. This is cheap and takes seconds to minutes.

    PostgreSQL
    ANALYZE orders;
    MySQL
    ANALYZE TABLE orders;
    -- for skewed columns, a histogram:
    ANALYZE TABLE orders UPDATE HISTOGRAM ON customer_id WITH 64 BUCKETS;
    MongoDB
    db.orders.getPlanCache().clear()   // forgets cached plans; the next run plans again

    Look for: Run the plan again. Back to the old plan: done.

    Undo: Nothing to undo.

  2. 5Handle the value that breaks the planLow-risk change

    One customer with a million rows, or a prepared statement that switched to a generic plan.

    PostgreSQL
    -- see the generic plan a prepared statement may switch to (PostgreSQL 16 and later)
    EXPLAIN (GENERIC_PLAN) SELECT * FROM orders WHERE customer_id = $1;
    -- for one role, always plan with the real value:
    ALTER ROLE app_user SET plan_cache_mode = force_custom_plan;
    MySQL
    -- a hint, in the query, for the big case
    SELECT /*+ INDEX(orders orders_customer_created_idx) */ * FROM orders WHERE customer_id = 42;
    MongoDB
    db.orders.find({ customer_id: 42 }).hint({ customer_id: 1, created_at: -1 })

    Look for: Pin the plan only as a bandage, and write down why.

    Undo: PostgreSQL: ALTER ROLE app_user RESET plan_cache_mode;

  3. 6If the query text changed in a deploy: roll backLow-risk change

    A new filter or a new ORDER BY is a new plan.

    In the shell
    kubectl rollout undo deployment/<app> -n <namespace>

    Look for: The old query and its old plan come back.

Confirm it is fixed
  1. 7Confirm the plan stayed fixedOnly reads

    The query's average time back to normal for an hour, through some traffic.

    PostgreSQL
    -- needs the pg_stat_statements extension
    SELECT calls, round(total_exec_time) AS total_ms,
           round(mean_exec_time::numeric, 2) AS mean_ms,
           rows, left(query, 80) AS query
    FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 10;
    MySQL
    SELECT query, exec_count, total_latency, avg_latency,
           rows_examined_avg, rows_sent_avg
    FROM sys.statement_analysis LIMIT 10;   -- sorted by total latency

    Look for: Plans can flip back: check again tomorrow.

What changes on your platform
On RDS or Aurora
  • Performance Insights keeps SQL history: compare the query's load per call today with last week. After a major version upgrade on RDS, run ANALYZE on PostgreSQL: statistics may be missing.
  • pg_hint_plan and auto_explain are available as extensions on RDS PostgreSQL, through the parameter group.
On Kubernetes
  • Nothing different. If the operator restarted the pod during the incident, the plan cache is cold: compare after a few minutes of traffic.
Escalate, or get a second DBA, when
  • ANALYZE did not fix it and the query serves a critical path.
  • The fix needs a new index on a large table, or a hint in application code.

Get the application team on a call

When
  • The slow query is new or changed in a deploy.
  • It is slow only for some values: big customers, old accounts.
Ask them
  • What does this query do for the user? Which values are slow?
  • Did the query, its filters or its sort change?
  • How many rows do the biggest customers have compared with a typical one?
  • Does it need every column it selects, and every row it fetches?
What to suggest, and when it fits
A composite index that matches the queryEquality columns first, then the range or sort column.
Rewrite for the big caseKeyset paging instead of OFFSET, a narrower SELECT, or a separate path for very large tenants.
Cache itAn expensive result that is read often and changes rarely.
Precompute itA summary table or materialized view refreshed on a schedule, for dashboards and counts.
Status update to post
<feature> is slow because one query changed its plan. We are <action>. Other features are not affected. Next update <time>.

Done when: The query is back to its normal time for an hour, and you know why the plan changed.

Don't
  • Restart the database to fix a plan. It may come back the same, and the cache goes cold.
  • Add an index without reading the plan. It may not be the one the query needs.

Postmortem: so it does not happen again

Prevent it
  • ANALYZE after every big load, delete, restore or major upgrade, as a step in the runbook for those jobs.
  • Lower autovacuum_analyze_scale_factor on large, fast-changing tables.
  • Test queries with the data shape of the biggest customer, not the average one.
Catch it earlier
  • Alert when one fingerprint's mean time rises several times over its baseline.
  • Log slow queries with their plans (auto_explain in PostgreSQL).
Automate it
  • An agent can compare today's plan for the top queries with yesterday's and flag any that changed shape.
  • Run ANALYZE automatically at the end of every bulk job.

Reading plans line by line: Reference. Try it on a real database: Guided tutorials.

Everything is slow and the disk is busyRead latency is up across many queries. Disk reads per second climbed, and CPU waits on I/O.Open the playbookClose · 7 steps
You are here if
  • Read latency up across many queries
  • Disk queue depth high, or IOPS flat at the volume's limit
  • CPU waits on I/O

Start here. Check whether you are hitting the volume's limit, then find out what is reading: hot data that no longer fits in memory, or one new scan pushing everything out.

Likely causes, most common first
  1. The data that is read often no longer fits in memory, so pages are read from disk again and again.
  2. A new report or job scans large tables and pushes hot pages out of the cache.
  3. A backup, vacuum or compaction is competing for the disk.
  4. The cloud volume ran out of burst credits or provisioned IOPS.
Confirm and scope
  1. 1Confirm the disk is the limitOnly reads

    A line flat at the provisioned IOPS or throughput is the tell. So is gp2 burst balance at zero.

    In the shell
    iostat -x 1 5        # r_await, w_await and %util on the data volume
    # on AWS also look at the volume's queue length, and BurstBalance for gp2
    # AWS: CloudWatch ReadIOPS, WriteIOPS, DiskQueueDepth, BurstBalance for the volume

    Look for: Await in tens of ms and utilization near 100 percent, or IOPS flat at the cap.

Find the cause
  1. 2Has the share served from memory fallen?Only reads

    If it fell, the working set grew or something is scanning.

    PostgreSQL
    SELECT blks_hit, blks_read,
           round(100.0 * blks_hit / nullif(blks_hit + blks_read, 0), 2) AS hit_pct
    FROM pg_stat_database WHERE datname = current_database();
    MySQL
    SHOW GLOBAL STATUS LIKE 'Innodb_buffer_pool_read%';
    -- Innodb_buffer_pool_reads (from disk) against Innodb_buffer_pool_read_requests
    MongoDB
    const c = db.serverStatus().wiredTiger.cache;
    [c['bytes currently in the cache'], c['maximum bytes configured'], c['pages read into cache']]

    Look for: Two readings a minute apart, compared with yesterday.

  2. 3Find who reads the mostOnly reads

    One report or job usually explains it.

    PostgreSQL
    SELECT calls, shared_blks_read, round(total_exec_time) AS total_ms, left(query, 80)
    FROM pg_stat_statements ORDER BY shared_blks_read DESC LIMIT 10;
    MySQL
    SELECT * FROM sys.statements_with_full_table_scans LIMIT 10;
    SELECT * FROM sys.io_global_by_file_by_latency LIMIT 10;
    MongoDB
    db.system.profile.find({}, { ns: 1, docsExamined: 1, millis: 1, planSummary: 1 })
      .sort({ docsExamined: -1 }).limit(10)

    Look for: A new report or a scan without an index.

  3. 4Check background workOnly reads

    Backups, vacuum, checkpoints and compaction all use the disk.

    PostgreSQL
    SELECT pid, relid::regclass, phase, heap_blks_scanned, heap_blks_total
    FROM pg_stat_progress_vacuum;
    SELECT * FROM pg_stat_checkpointer;   -- PostgreSQL 17 and later; pg_stat_bgwriter before
    MySQL
    SHOW ENGINE INNODB STATUS\G   -- BUFFER POOL AND MEMORY, and pending flushes
    MongoDB
    db.serverStatus().wiredTiger.cache['tracked dirty bytes in the cache']
    In the shell
    ps aux | grep -E 'pg_basebackup|xtrabackup|mysqldump|mongodump' | grep -v grep

    Look for: A backup at peak: move it. Checkpoints every few minutes: max_wal_size is too small.

Stop the bleeding, least risky first
  1. 5Stop or move the heavy readerLow-risk changeTime box: 5 minutes

    Keep the live traffic; move the report.

    PostgreSQL
    SELECT pg_cancel_backend(<pid>);   -- the report found in step 3
    MySQL
    KILL QUERY <thread id>;
    MongoDB
    db.killOp(<opid>)

    Look for: Disk wait falls within a minute.

    Undo: Rerun it on a replica or off-peak.

  2. 6Raise the volume's IOPS or throughputLow-risk change

    gp3 and io2 can be changed online. It costs money, so use it when the load is real.

    In the shell
    aws ec2 modify-volume --volume-id <vol> --iops <n> --throughput <MBps>
    # RDS: modify-db-instance --iops <n> (and --storage-type gp3)

    Look for: Latency falls as the change applies.

Confirm it is fixed
  1. 7Confirm latency is backOnly reads

    Disk wait and the hit ratio back to normal for 15 minutes.

    PostgreSQL
    SELECT blks_hit, blks_read,
           round(100.0 * blks_hit / nullif(blks_hit + blks_read, 0), 2) AS hit_pct
    FROM pg_stat_database WHERE datname = current_database();
    MySQL
    SHOW GLOBAL STATUS LIKE 'Innodb_buffer_pool_read%';
    -- Innodb_buffer_pool_reads (from disk) against Innodb_buffer_pool_read_requests
    MongoDB
    const c = db.serverStatus().wiredTiger.cache;
    [c['bytes currently in the cache'], c['maximum bytes configured'], c['pages read into cache']]

    Look for: Watch the next peak.

What changes on your platform
On RDS or Aurora
  • ReadIOPS, WriteIOPS, ReadLatency, DiskQueueDepth and, on gp2, BurstBalance. gp3 IOPS and throughput can be raised online, but on RDS this is a storage change: the six hour rule applies.
  • Enhanced Monitoring shows the OS view (per process I/O) that CloudWatch does not.
On Kubernetes
  • Disk limits come from the storage class: cloud volume type and size. A database on network storage with a small volume gets small IOPS.
    kubectl get pvc <pvc> -n <ns> -o jsonpath='{.spec.storageClassName}'
Escalate, or get a second DBA, when
  • The volume is at its maximum and the load is real: you need more memory or a different volume type.
  • Vacuum or compaction is the reader and cannot be paused safely.

Get the application team on a call

When
  • A new report, export or job is the heavy reader.
  • The working set outgrew memory because the data grew.
Ask them
  • What does this job need, how often, and how fresh?
  • Which data do users read most: the last day, the last month, everything?
  • Can the export run from a replica or a snapshot?
What to suggest, and when it fits
Move it to a replica or warehouseReports and exports read big ranges; keep them off the primary.
Index the scanIf it scans for a small result, it needs an index.
Cache the hot readsIf the same data is read again and again.
Archive cold dataKeep the hot set small enough to fit in memory.
Status update to post
Database <name>: storage is saturated, so reads are slow. Cause: <what>. We are <action>. Next update <time>.

Done when: Disk latency and hit ratio are back to normal, and the heavy reader has a new home or an index.

Don't
  • Cancel autovacuum again and again. It comes back, and the dead rows keep growing.
  • Buy IOPS before you know what is reading.

Postmortem: so it does not happen again

Prevent it
  • Reports and exports on replicas by default.
  • Memory sized for the working set, reviewed every quarter as data grows.
  • Backups and heavy maintenance outside peak hours.
Catch it earlier
  • Alert on disk queue depth and on IOPS near the provisioned limit.
  • Alert on BurstBalance below 20 percent on gp2.
  • Track the buffer cache hit ratio against its own baseline.
Automate it
  • An agent can name the top reader by blocks read within a minute of the alert.
  • Schedule heavy jobs with a check that pauses them when disk latency rises.

How big the hot data is: Capacity calculator.

Out of memory, or the server restartedThe database process was killed by the operating system, or restarted on its own. Clients saw connection errors.Open the playbookClose · 7 steps
You are here if
  • The database restarted on its own
  • Connection errors for a minute, then recovery
  • OOM killer lines in the kernel log
  • A failover you did not start

Start here. First make sure the database is up, in the right role, and not in a crash loop, and that only one node thinks it is the primary. Root cause comes after.

Likely causes, most common first
  1. Too many connections, each with its own memory for sorts and hashes (work_mem in PostgreSQL is per operation, not per connection).
  2. A buffer pool or cache set too close to the machine's total memory.
  3. A large query building a huge hash or sort in memory.
  4. Something else on the same machine using memory: a backup, an agent, another service.
Confirm and scope
  1. 1Is it up, and in the right role?Only reads

    After a crash the database replays its log first. On a cluster, a failover may have happened.

    PostgreSQL
    SELECT pg_is_in_recovery(), now() - pg_postmaster_start_time() AS up_for;
    MySQL
    SHOW GLOBAL STATUS LIKE 'Uptime';
    SELECT @@read_only, @@super_read_only;
    MongoDB
    rs.status().members.map(m => [m.name, m.stateStr])

    Look for: Up and with the expected role: step 3.

    • If it keeps restarting → step 5: Stop a crash loop
    • If a failover happened → Check the old primary rejoined as a replica, and that apps point at the new one. Two primaries is a bigger outage than a restart.
Find the cause
  1. 2Confirm the OOM killer and the timeOnly reads

    The kernel log names the process and the minute.

    PostgreSQL
    -- in the PostgreSQL log:
    -- server process (PID ...) was terminated by signal 9: Killed
    MySQL
    -- in the MySQL error log: mysqld restarted, then InnoDB crash recovery
    MongoDB
    // in the mongod log: no shutdown message before the next startup
    In the shell
    dmesg -T | grep -i -E 'killed process|out of memory'
    journalctl -k --since '2 hours ago' | grep -i -E 'oom|killed process'

    Look for: Line it up with your graphs: what spiked at that minute?

  2. 3Add up what the configuration allowsOnly reads

    Cache plus per-connection memory times connections must fit with room to spare.

    PostgreSQL
    SELECT name, setting, unit FROM pg_settings
    WHERE name IN ('shared_buffers', 'work_mem', 'maintenance_work_mem',
                   'hash_mem_multiplier', 'max_connections', 'autovacuum_max_workers');
    -- work_mem is per sort or hash, so one query can use it several times
    MySQL
    SELECT @@innodb_buffer_pool_size / 1024 / 1024 / 1024 AS buffer_pool_gb,
           @@max_connections, @@sort_buffer_size, @@join_buffer_size, @@tmp_table_size;
    SELECT * FROM sys.memory_global_by_current_bytes LIMIT 10;
    MongoDB
    db.serverStatus().wiredTiger.cache['maximum bytes configured']
    // default: 50 percent of (RAM - 1 GB)
    In the shell
    free -g

    Look for: A cache near total RAM, or many connections each allowed big sorts.

  3. 4Find what ran when it diedLow-risk change

    One query with a huge sort or hash is a common trigger.

    PostgreSQL
    -- the log lines just before the kill; to log big sorts from now on:
    ALTER SYSTEM SET log_temp_files = '100MB';
    SELECT pg_reload_conf();
    MySQL
    SELECT * FROM performance_schema.memory_summary_by_thread_by_event_name
    ORDER BY current_number_of_bytes_used DESC LIMIT 10;
    MongoDB
    // the slow operations in the mongod log just before the restart

    Look for: Write it down: it is the one to fix.

Stop the bleeding, least risky first
  1. 5Stop a crash loopRisky: a human decides

    If it is killed again as soon as traffic returns, take load off before it comes back: fewer connections, the heavy job stopped.

    In the shell
    # stop the job or app that triggered it, or lower its pool, then start the database
    systemctl status postgresql mysql mongod 2>/dev/null | head -20

    Look for: It stays up for 15 minutes with traffic.

  2. 6Leave headroomLow-risk change

    Lower the memory for the role that runs big queries; leave room for the OS.

    PostgreSQL
    -- lower work_mem for the role that runs big reports, not for everyone
    ALTER ROLE report_user SET work_mem = '64MB';
    -- PostgreSQL's docs recommend vm.overcommit_memory = 2 on dedicated servers
    MySQL
    -- leave room: a buffer pool around 70 to 75 percent of RAM on a dedicated server
    SET PERSIST innodb_buffer_pool_size = <bytes>;   -- resizes online
    MongoDB
    # mongod.conf
    storage:
      wiredTiger:
        engineConfig:
          cacheSizeGB: <smaller value>

    Look for: No OOM through the next peak.

    Undo: Set the old values back.

Confirm it is fixed
  1. 7Confirm it is stableOnly reads

    Up, the right role, memory below 85 percent through a peak.

    PostgreSQL
    SELECT pg_is_in_recovery(), now() - pg_postmaster_start_time() AS up_for;
    MySQL
    SHOW GLOBAL STATUS LIKE 'Uptime';
    SELECT @@read_only, @@super_read_only;
    MongoDB
    rs.status().members.map(m => [m.name, m.stateStr])

    Look for: Watch the next day's peak too.

What changes on your platform
On RDS or Aurora
  • There is no kernel log. Look for FreeableMemory falling and SwapUsage rising, and for "restarted" or "failover" in RDS events.
    aws rds describe-events --source-type db-instance --source-identifier <id> --duration 1440
  • Parameter groups use formulas such as {DBInstanceClassMemory*3/4} for the buffer pool. A custom value copied from a bigger instance is a common cause.
On Kubernetes
  • An OOM kill shows as Last State: Terminated, Reason: OOMKilled, exit code 137 on the container.
    kubectl describe pod <db-pod> -n <ns> | grep -A5 'Last State'
    kubectl logs <db-pod> -n <ns> --previous | tail -50
  • The database's memory settings must fit the container limit, not the node. shared_buffers or the buffer pool sized for the node gets the pod killed.
Escalate, or get a second DBA, when
  • A crash loop.
  • Two nodes claim to be primary.
  • The database does not finish crash recovery.

Get the application team on a call

When
  • One query or job caused it.
  • A new service added many connections.
Ask them
  • What ran at <time>? Any new report, export or batch job?
  • How many connections do your services open now?
  • Does any query sort or group millions of rows?
What to suggest, and when it fits
Paginate or streamDo not pull millions of rows into one result.
Move it to a warehouseBig aggregations belong in an analytics store.
Use a poolerFewer real connections means less memory.
Status update to post
Database <name> restarted at <time> because it ran out of memory. It is <up / recovering>. Cause: <what>. We are <action>. Next update <time>.

Done when: The database has been stable through a peak, and the memory budget adds up with room to spare.

Don't
  • Give the cache 90 percent of RAM on a server that also runs other things.
  • Add swap and call it fixed. A database in swap is slower than one that restarts.

Postmortem: so it does not happen again

Prevent it
  • Size the cache and per-connection memory with a written formula, reviewed when connections grow.
  • work_mem raised only for the roles that need it.
  • vm.overcommit_memory = 2 on dedicated PostgreSQL servers, as its docs recommend.
Catch it earlier
  • Alert on memory above 85 percent.
  • Alert on any unplanned restart or failover.
Automate it
  • An agent can collect the kernel log, the database log and the active queries from the minute before, and post them as one summary.

Where memory goes in each engine: PostgreSQL, MySQL, MongoDB.

Writes and commits are slowReads are fine, but inserts and updates take longer. Commit latency rose while CPU is low.Open the playbookClose · 6 steps
You are here if
  • Inserts and updates slow while reads are fine
  • Commit latency up with low CPU
  • All writes hang at once: classic sign of a synchronous standby that went away

Start here. Find what commits are waiting on. All writes hanging at once usually means a synchronous standby is gone; slower writes usually mean the log disk.

Likely causes, most common first
  1. Every commit waits for a disk flush, and the log disk is slow or shared.
  2. Synchronous replication: each commit waits for a standby that is far away or overloaded.
  3. Too many indexes: every insert updates every one of them.
  4. Hot pages or rows that many sessions write at once.
Confirm and scope
  1. 1What are commits waiting onOnly reads

    This decides the rest.

    PostgreSQL
    SELECT wait_event_type, wait_event, count(*)
    FROM pg_stat_activity WHERE state = 'active'
    GROUP BY 1, 2 ORDER BY 3 DESC;
    -- WALSync or WALWrite: the disk.  SyncRep: a synchronous standby.
    MySQL
    SELECT event_name, count_star, sum_timer_wait / 1e12 AS total_s
    FROM performance_schema.file_summary_by_event_name
    WHERE event_name LIKE '%innodb_log_file%';
    SHOW GLOBAL STATUS LIKE 'Rpl_semi_sync_source%';
    MongoDB
    db.serverStatus().opLatencies.writes
    // with writeConcern majority, writes also wait for secondaries

    Look for: Read the wait events.

Find the cause
  1. 2Which standby is slow or goneOnly reads

    With synchronous replication every commit waits for it. If it is gone, every commit waits forever.

    PostgreSQL
    SHOW synchronous_standby_names;
    SELECT application_name, sync_state, state, flush_lag
    FROM pg_stat_replication;
    MySQL
    SHOW GLOBAL STATUS LIKE 'Rpl_semi_sync_source_status';
    SHOW VARIABLES LIKE 'rpl_semi_sync_source_timeout';
    MongoDB
    rs.printSecondaryReplicationInfo()

    Look for: A missing or far-behind sync standby.

  2. 3Measure the log diskOnly reads

    Every durable commit waits for one flush.

    In the shell
    iostat -x 1 5                  # w_await on the log volume
    pg_test_fsync -f /data/test    # PostgreSQL's tool: flushes per second on this disk

    Look for: A flush in milliseconds: the volume is slow, shared or throttled.

  3. 4Check for too many indexesOnly reads

    Every insert updates every index.

    PostgreSQL
    SELECT indexrelid::regclass AS index, idx_scan,
           pg_size_pretty(pg_relation_size(indexrelid)) AS size
    FROM pg_stat_user_indexes WHERE idx_scan = 0
    ORDER BY pg_relation_size(indexrelid) DESC LIMIT 10;
    MySQL
    SELECT * FROM sys.schema_unused_indexes;
    MongoDB
    db.orders.aggregate([{ $indexStats: {} }])   // accesses.ops near 0 means unused

    Look for: Not a mid-incident fix: put it in the postmortem.

Stop the bleeding, least risky first
  1. 5Decide: keep waiting, or drop to asynchronous for nowRisky: a human decidesTime box: Decide within 10 minutes

    Dropping to async restores writes at once, and for that time a failover can lose the last commits. This is the service owner's decision, made in the channel, in writing.

    PostgreSQL
    -- a dead synchronous standby: commits stop waiting for it
    ALTER SYSTEM SET synchronous_standby_names = '';
    SELECT pg_reload_conf();
    -- for a non-critical role only: commits return before the flush
    ALTER ROLE events_user SET synchronous_commit = off;
    MySQL
    -- semi-sync falls back to async after this many ms without an ack
    SET PERSIST rpl_semi_sync_source_timeout = 1000;
    MongoDB
    // for non-critical writes only, in the app:
    // { writeConcern: { w: 1 } } instead of majority

    Look for: Writes flow again.

    Undo: Set synchronous_standby_names back once the standby is healthy.

Confirm it is fixed
  1. 6Confirm writes are normalOnly reads

    Commit latency back to baseline.

    PostgreSQL
    SELECT wait_event_type, wait_event, count(*)
    FROM pg_stat_activity WHERE state = 'active'
    GROUP BY 1, 2 ORDER BY 3 DESC;
    -- WALSync or WALWrite: the disk.  SyncRep: a synchronous standby.
    MySQL
    SELECT event_name, count_star, sum_timer_wait / 1e12 AS total_s
    FROM performance_schema.file_summary_by_event_name
    WHERE event_name LIKE '%innodb_log_file%';
    SHOW GLOBAL STATUS LIKE 'Rpl_semi_sync_source%';
    MongoDB
    db.serverStatus().opLatencies.writes
    // with writeConcern majority, writes also wait for secondaries

    Look for: If you dropped to async: a ticket to restore it, with an owner.

What changes on your platform
On RDS or Aurora
  • Multi-AZ instances replicate every write synchronously to the standby, so commit latency includes that. Multi-AZ DB clusters (two readable standbys) wait for one of two. Aurora writes six copies across three zones and needs four.
  • WriteLatency and CommitLatency (Aurora) in CloudWatch.
On Kubernetes
  • Check the storage class: network-attached volumes add latency to every flush. Operators can also run synchronous replicas: check the cluster resource.
    kubectl get cluster <name> -n <ns> -o yaml | grep -i -A3 sync
Escalate, or get a second DBA, when
  • Dropping to async is on the table: that is a data loss decision.
  • The log volume is the problem and cannot be changed quickly.

Get the application team on a call

When
  • Write volume or write pattern changed.
  • The durability decision (sync or async) affects their data.
Ask them
  • Did write volume change? Are rows written one per transaction?
  • For this data, what is worse: a few seconds of writes failing, or losing the last second of writes in a failover?
What to suggest, and when it fits
Batch commitsMany rows per transaction instead of one.
Durability per data typeEvents or metrics can use asynchronous commit; payments cannot.
Two sync standbysANY 1 of 2 standbys, so one failing does not stop writes.
Status update to post
Database <name>: writes are <slow / stopped>. Cause: <standby / disk>. We are <action>. <If async: until fixed, a failover could lose the last seconds of writes.> Next update <time>.

Done when: Commit latency is normal, and any durability change has a ticket and an owner to restore it.

Don't
  • Turn off fsync, or set innodb_flush_log_at_trx_commit away from 1 for the whole server. A crash can corrupt data or lose commits.
  • Switch to async without the owner agreeing to the data-loss window.

Postmortem: so it does not happen again

Prevent it
  • Synchronous replication with a quorum of standbys (ANY 1 of 2), never a single required one.
  • The WAL or redo log on a fast volume of its own.
Catch it earlier
  • Alert on commit latency, and on a synchronous standby disconnecting.
  • Alert on WAL sync time.
Automate it
  • An agent can detect a dead sync standby in seconds and prepare the async switch for a human to approve, with the data-loss window stated.

What a commit waits for: Synchronous replication and failover.

Tables grow but rows do notTable size keeps rising while the row count is flat. Scans get slower over weeks.Open the playbookClose · 6 steps
You are here if
  • PostgreSQL warns "database must be vacuumed within N transactions"
  • PostgreSQL refuses writes "to avoid wraparound data loss": a full outage
  • Tables grow while row counts do not; MySQL history list length in the millions

Start here. If PostgreSQL is warning about wraparound, everything else waits: find what holds the oldest snapshot, remove it, and vacuum the oldest tables. Bloat on its own is a planning problem, not an outage.

Likely causes, most common first
  1. Old row versions are not being removed because a long transaction or a forgotten replication slot holds them.
  2. Cleanup cannot keep up with the update rate on one hot table.
  3. Space freed inside the files is reused, not given back to the operating system, which is normal.
Confirm and scope
  1. 1How close is wraparound?Only reads

    Writes stop near 2 billion. This number decides how urgent the next hour is.

    PostgreSQL
    SELECT datname, age(datfrozenxid) AS xid_age FROM pg_database ORDER BY 2 DESC;
    SELECT relname, age(relfrozenxid) AS xid_age
    FROM pg_class WHERE relkind = 'r' ORDER BY 2 DESC LIMIT 10;
    MySQL
    -- not applicable to MySQL
    MongoDB
    // not applicable to MongoDB

    Look for: Over a billion and climbing: treat it as an outage.

Find the cause
  1. 2Find what stops cleanupOnly reads

    An old transaction, an abandoned replication slot, a forgotten prepared transaction, or a replica with hot_standby_feedback.

    PostgreSQL
    -- the oldest snapshots
    SELECT pid, usename, state, now() - xact_start AS age, backend_xmin
    FROM pg_stat_activity WHERE backend_xmin IS NOT NULL
    ORDER BY age(backend_xmin) DESC LIMIT 5;
    SELECT slot_name, active, xmin, catalog_xmin FROM pg_replication_slots;
    SELECT gid, prepared FROM pg_prepared_xacts;
    MySQL
    SELECT trx_mysql_thread_id, trx_started, trx_state
    FROM information_schema.innodb_trx ORDER BY trx_started LIMIT 5;
    MongoDB
    db.getSiblingDB('admin').aggregate([
      { $currentOp: { allUsers: true, idleSessions: true } },
      { $match: { transaction: { $exists: true } } }])

    Look for: The oldest of these is the blocker.

  2. 3For plain bloat: measure the dead rowsOnly reads

    Not urgent unless the disk is filling.

    PostgreSQL
    SELECT relname, n_live_tup, n_dead_tup, last_autovacuum,
           pg_size_pretty(pg_total_relation_size(relid)) AS size
    FROM pg_stat_user_tables ORDER BY n_dead_tup DESC LIMIT 10;
    MySQL
    SELECT table_name, ROUND(data_free / 1024 / 1024) AS free_mb,
           ROUND((data_length + index_length) / 1024 / 1024) AS used_mb
    FROM information_schema.tables WHERE table_schema = DATABASE()
    ORDER BY data_free DESC LIMIT 10;
    SELECT count FROM information_schema.innodb_metrics WHERE name = 'trx_rseg_history_len';
    MongoDB
    db.orders.stats().wiredTiger['block-manager']['file bytes available for reuse']

    Look for: Plan the fix; do not rebuild tables in the middle of the day.

Stop the bleeding, least risky first
  1. 4Remove the blockerRisky: a human decides

    Nothing else helps until the oldest snapshot is gone.

    PostgreSQL
    SELECT pg_terminate_backend(<pid>);           -- the old transaction
    SELECT pg_drop_replication_slot('old_slot');  -- only if nobody will read it again
    ROLLBACK PREPARED '<gid>';                     -- a forgotten prepared transaction
    MySQL
    KILL <thread id>;   -- the old transaction; its rollback can take a while
    MongoDB
    db.killOp(<opid>)

    Look for: The oldest xmin moves forward.

    Undo: None. A dropped slot's consumer needs a rebuild.

  2. 5Vacuum the oldest tables firstLow-risk changeTime box: As long as it takes; report progress every 15 minutes

    Start with the tables with the oldest relfrozenxid. Since PostgreSQL 14, vacuum switches to a faster failsafe mode by itself when wraparound is close. Single-user mode is no longer needed in typical cases.

    PostgreSQL
    VACUUM (FREEZE, VERBOSE) <the oldest table>;
    -- watch it from another session
    SELECT * FROM pg_stat_progress_vacuum;

    Look for: age(datfrozenxid) falls after each table.

Confirm it is fixed
  1. 6Confirm the age is fallingOnly reads

    age(datfrozenxid) well under autovacuum_freeze_max_age, and autovacuum keeping up.

    PostgreSQL
    SELECT datname, age(datfrozenxid) AS xid_age FROM pg_database ORDER BY 2 DESC;
    SELECT relname, age(relfrozenxid) AS xid_age
    FROM pg_class WHERE relkind = 'r' ORDER BY 2 DESC LIMIT 10;
    MySQL
    -- not applicable to MySQL
    MongoDB
    // not applicable to MongoDB
What changes on your platform
On RDS or Aurora
  • MaximumUsedTransactionIDs in CloudWatch is the wraparound age. Alert on it. RDS has no single-user mode, so remove blockers early.
  • pg_repack is available as an extension on RDS PostgreSQL.
On Kubernetes
  • Nothing different, except the PVC: a rebuild needs free space for a full copy of the table.
Escalate, or get a second DBA, when
  • PostgreSQL has stopped accepting writes.
  • The age is over a billion and the blocker is a slot or replica someone else owns.

Get the application team on a call

When
  • An app keeps long transactions or long-running reports open.
  • A CDC connector or replica owns the slot that blocks cleanup.
Ask them
  • What keeps a transaction open for hours? A report, a cursor, a forgotten session?
  • Is your connector still reading this slot?
  • Do you run hours-long queries on a replica with hot_standby_feedback on?
What to suggest, and when it fits
Short transactionsLong reports belong on a replica without hot_standby_feedback, or in a warehouse.
Timeoutsidle_in_transaction_session_timeout and statement_timeout for app users.
Partition big tablesSmaller tables vacuum and freeze faster, and old partitions can be dropped.
Status update to post
Database <name>: PostgreSQL needs an urgent vacuum to keep accepting writes. Cause: <blocker>. We have <removed it> and are vacuuming. Writes <are / are not> affected. Next update <time>.

Done when: The age is falling and well below the alert line, the blocker is gone, and autovacuum keeps up on its own.

Don't
  • Run VACUUM FULL on a busy table. It locks the table until it finishes.
  • Disable autovacuum on a table because it is busy. That is how wraparound happens.

Postmortem: so it does not happen again

Prevent it
  • Timeouts for idle transactions and statements.
  • max_slot_wal_keep_size, and monitoring of slot consumers.
  • Autovacuum tuned for the biggest tables: more workers, a higher cost limit.
Catch it earlier
  • Alert on age(datfrozenxid) above 500 million, long before PostgreSQL warns.
  • Alert on the oldest transaction age and on inactive slots.
Automate it
  • An agent can track wraparound age daily and open a ticket with the oldest tables and the current blocker long before it is urgent.

Why it happens: Start here, and the MVCC timeline lab.

High availability and platforms

High availability: what it means, how each engine does it, and what breaks

The failures that come from the HA layer itself: Patroni and etcd, InnoDB Cluster, MongoDB replica sets, managed failovers on RDS and Aurora, and databases running in pods. First what high availability means and how each engine does it, then, for each setup, the issues DBAs keep seeing with the usual fix, and the playbooks.

What high availability means

High availability means the database keeps taking reads and writes when one server, one disk or one zone fails. It never means zero downtime: there is always a gap while the system notices the failure and switches. Two numbers describe any setup:

RTORecovery time: how long until writes work again. Seconds to a couple of minutes for the setups below.
RPORecovery point: how much confirmed data a failover can lose. Zero with synchronous or majority writes, a few seconds or less with asynchronous replication.

Every HA setup does the same three jobs. The engines differ in which of them are built in.

1

Keep a copy

Another server has the data, current to the last second or the last commit. That is replication.

2

Decide who is primary

Something notices the primary is gone and picks exactly one replacement. Exactly one is the hard part: two primaries taking different writes is worse than an outage.

3

Send clients to it

Apps have to find the new primary: a router, a proxy, DNS, or a driver that watches the cluster.

HA is not a backup. A DROP TABLE or a bad UPDATE reaches every replica in milliseconds. You still need backups and point-in-time recovery: see Backups and restore time.

How each engine does it

PostgreSQL + PatroniMySQL InnoDB ClusterMongoDB replica setRDS and Aurora
Keeps a copy withStreaming WAL replication. Asynchronous by default; synchronous if you ask for it.Group Replication: a majority agrees on every transaction before it commits.The oplog, replayed by secondaries. w: majority is the default write concern since 5.0.Multi-AZ: a synchronous standby. Aurora: six copies across three zones, four needed for a write.
Who decides the new primaryNot built in. Patroni runs on every node and uses etcd (or Consul, ZooKeeper) to hold one leader key.Built in. Group Replication elects a new primary; MySQL Shell (AdminAPI) sets it up and repairs it.Built in. Members hold an election, using a Raft-like consensus protocol.AWS.
How clients find itHAProxy checking Patroni's REST API, a virtual IP, or a multi-host connection string with target_session_attrs=read-write.MySQL Router: port 6446 for writes, 6447 for reads.The drivers discover the set and follow the primary.A DNS endpoint that moves to the new primary.
Typical time to switchUp to about 30 seconds with the default ttl, plus the time for clients to reconnect.Seconds: about 5 to suspect a member and 5 more to expel it, by default.A median of 12 seconds or less with default settings (MongoDB docs).Multi-AZ instance 60 to 120 s. Multi-AZ cluster under 35 s. Aurora under 60 s, often under 30 s (AWS docs).
What a failover can loseWith async replication, the last commits not yet streamed. Patroni will not promote a replica more than 1 MB behind by default. With synchronous_mode on, nothing confirmed is lost.Nothing it confirmed, in single-primary mode: a majority already had it.Nothing written with w: majority. Writes with w: 1 can be rolled back.Multi-AZ and Aurora: nothing committed.
What you runPostgreSQL on 2 or more nodes, Patroni, a 3-node etcd, HAProxy.3 or more MySQL servers, MySQL Router, MySQL Shell.3 data-bearing mongod (avoid arbiters).Nothing yourself. You pay for the standby.

The short version: MongoDB has all three jobs built in. MySQL has the copy and the election built in with Group Replication, and adds Router to send clients. PostgreSQL has only the copy built in; the decision and the routing come from tools around it, most often Patroni with etcd and HAProxy. RDS and Aurora do all three for you, at the cost of control and a longer switch on a Multi-AZ instance.

Watch a failover in each

Pick the engine. Each one stops once to ask you a question.

Why majorities and leader keys matter: Consensus and leaders and CAP as settings you choose. The trade-off between waiting for a standby and losing writes: What a commit waits for.

Issues we see, and what we do

Patroni with etcd (PostgreSQL)

IssueWhat you seeWhat we do
etcd loses quorumPrimary demotes to read-only; no LeaderRestore etcd majority; Patroni elects by itself Playbook →
etcd NOSPACE alarmPatroni cannot write its key; cluster goes read-onlyCompact, defrag, disarm; schedule auto-compaction Playbook →
Slow etcd diskLeader changes, "failed to update leader lock"Move etcd to its own fast disk Playbook →
Short pauses trigger failoversFailovers with nothing really brokenPause, fix the cause, set ttl and retry_timeout to fit Playbook →
Old primary divergedWill not rejoin: timeline errorsuse_pg_rewind, else patronictl reinit Playbook →
synchronous_mode_strict with no sync standbyAll writes hangBring a standby back, or turn strict off with the owner agreeing Playbook →
Apps keep old connectionsErrors after the failover finishedRestart pools; route through HAProxy on the REST API Playbook →
Patroni: no leader, or the primary went read-onlyWrites fail with "cannot execute ... in a read-only transaction". patronictl shows no Leader, or every member as a Replica.Open the playbookClose · 7 steps
You are here if
  • App errors: read-only transaction
  • patronictl list shows no Leader
  • Patroni logs: "failed to update leader lock" or "demoting self"

Start here. Look at etcd before PostgreSQL. A Patroni cluster with no leader is almost always a DCS problem, and PostgreSQL is doing exactly what it should.

Likely causes, most common first
  1. etcd lost quorum or is unreachable, so the leader cannot renew its key and demotes itself. This is Patroni protecting you from split brain.
  2. etcd is out of space (the NOSPACE alarm) or its disk is so slow that requests time out.
  3. A network split put the primary on the minority side.
  4. The cluster is paused (maintenance mode) and someone stopped the primary.
Confirm and scope
  1. 1See what Patroni thinksOnly reads

    Roles, states, lag and timeline for every member.

    Patroni and etcd
    patronictl -c /etc/patroni/patroni.yml list
    patronictl -c /etc/patroni/patroni.yml history | tail -5

    Look for: No Leader, or a Leader whose state is not running.

Find the cause
  1. 2Check etcd health and quorumOnly reads

    Patroni needs a majority of etcd members to keep the leader key.

    Patroni and etcd
    etcdctl endpoint health --cluster
    etcdctl endpoint status --cluster -w table   # leader, DB size, raft term
    etcdctl alarm list

    Look for: Read the result.

  2. 3Read the Patroni logs on the old primaryOnly reads

    They say why it stepped down.

    Patroni and etcd
    journalctl -u patroni --since '30 min ago' | grep -i -E 'demot|lock|dcs|timeout' | tail -30

    Look for: "failed to update leader lock" means it could not reach etcd in time; look at the network and etcd disk latency.

Stop the bleeding, least risky first
  1. 4Bring etcd back to a majorityLow-risk changeTime box: 15 minutes

    Start the stopped members or fix the network between them. Patroni elects a leader by itself once etcd answers.

    Patroni and etcd
    systemctl status etcd
    systemctl start etcd     # on the members that are down
    etcdctl member list -w table

    Look for: A leader appears in patronictl list within a loop or two (10 to 30 seconds).

  2. 5Clear the etcd space alarmLow-risk change

    etcd keeps old revisions until compacted. At the quota (2 GB by default) it refuses writes, so Patroni cannot write its key.

    Patroni and etcd
    rev=$(etcdctl endpoint status --write-out=json | grep -o '"revision":[0-9]*' | head -1 | cut -d: -f2)
    etcdctl compact $rev
    etcdctl defrag --cluster
    etcdctl alarm disarm

    Look for: alarm list is empty and Patroni elects a leader.

    Undo: Nothing to undo.

  3. 6If etcd cannot come back soon: run without it, on purposeRisky: a human decides

    Last resort. Patroni will not promote without a DCS. Pausing Patroni and promoting one node by hand means you, not Patroni, now guarantee there is only one primary.

    Patroni and etcd
    patronictl -c /etc/patroni/patroni.yml pause
    # on the node you choose, after checking it has the most WAL:
    sudo -u postgres pg_ctl promote -D <data dir>

    Look for: One writable primary, and every app pointed at it.

    Undo: patronictl -c /etc/patroni/patroni.yml resume, once etcd is healthy and the others follow this primary.

Confirm it is fixed
  1. 7Confirm one leader and healthy replicasOnly reads

    PostgreSQL
    SELECT pg_is_in_recovery();
    Patroni and etcd
    patronictl -c /etc/patroni/patroni.yml list

    Look for: One Leader, replicas streaming, lag near zero.

Escalate, or get a second DBA, when
  • etcd lost quorum and members will not start.
  • Anyone suggests promoting by hand: get a second DBA.

Get the application team on a call

When
  • Writes are failing and the app owners need to know whether to retry or wait.
Ask them
  • Can your app run read-only for a while, or should it fail fast?
  • Does it retry writes, and are those writes idempotent?
What to suggest, and when it fits
Fail fast on read-only errorsRetry with backoff instead of hammering a demoted primary.
Connect through a service that follows the leaderA Patroni REST check behind HAProxy, or a Kubernetes service the operator updates.
Status update to post
PostgreSQL cluster <name> has no writable primary because <etcd / network>. Reads work, writes fail. We are <action>. Next update <time>.

Done when: One leader, every replica streaming, etcd healthy with room under its quota.

Don't
  • Wipe etcd data or the Patroni key to "reset" the cluster.
  • Promote a replica with pg_ctl while Patroni is running and not paused. You can end up with two primaries.

Postmortem: so it does not happen again

Prevent it
  • Run etcd on its own fast disks, with three or five members across zones.
  • Schedule etcd compaction and defragmentation (auto-compaction-retention).
  • Consider Patroni failsafe_mode (Patroni 3.0 and later): the leader keeps running when etcd is down but every member can still see it.
Catch it earlier
  • Alert on etcd health, leader changes, DB size against quota, and fsync latency.
  • Alert on Patroni reporting no leader.
Automate it
  • An agent can check etcd health and the alarm list the moment Patroni reports no leader, and post which of the two problems it is.

Why Patroni demotes instead of guessing: Consensus and leaders.

Patroni: an unexpected failover, or failovers that keep happeningThe primary moved without anyone asking. Apps saw a burst of errors. Maybe it happened several times.Open the playbookClose · 6 steps
You are here if
  • patronictl history shows a new entry
  • Burst of connection errors
  • The timeline went up by one

Start here. Find out why the old primary lost its lease, then make sure the old primary came back as a replica and the apps follow the new one. Pause Patroni if it keeps flapping.

Likely causes, most common first
  1. The primary or its network paused longer than ttl (30 seconds by default): a VM pause, a long I/O stall, a network blip.
  2. etcd itself was slow, so the leader could not renew its key in time.
  3. The primary really died: OOM, disk full, hardware.
  4. Someone ran a failover or a node was drained for maintenance.
Confirm and scope
  1. 1When and to whomOnly reads

    The history shows each failover with its time and the new leader.

    Patroni
    patronictl -c /etc/patroni/patroni.yml history
    patronictl -c /etc/patroni/patroni.yml list

    Look for: A new leader, and whether the old one is back.

Find the cause
  1. 2Why the old leader lost its leaseOnly reads

    Its Patroni log just before the failover.

    Patroni
    journalctl -u patroni --since '<time - 5 min>' --until '<time + 2 min>' | grep -v -i 'no action'
    journalctl -k --since '<time - 5 min>' | tail -20    # OOM or I/O errors

    Look for: "failed to update leader lock", a missing heartbeat, or a crash.

  2. 3Did the apps follow?Only reads

    Apps that cached the old address, or pools that never reconnect, keep failing after the database is fine.

    PostgreSQL
    SELECT client_addr, application_name, count(*) FROM pg_stat_activity GROUP BY 1, 2 ORDER BY 3 DESC;
    Patroni
    curl -s http://<node>:8008/primary -o /dev/null -w '%{http_code}\n'   # 200 only on the leader

    Look for: Apps missing from the new primary: their pools hold dead connections. Restart those pods or services.

Stop the bleeding, least risky first
  1. 4Stop the flapping: pause PatroniLow-risk changeTime box: Until the cause is fixed, ideally under an hour

    Pausing stops automatic failover while you fix the cause. The current primary stays primary.

    Patroni
    patronictl -c /etc/patroni/patroni.yml pause --wait

    Look for: No new failovers. Remember to resume.

    Undo: patronictl -c /etc/patroni/patroni.yml resume

  2. 5Fix the cause, then tune the timingsLow-risk change

    If short pauses trigger failovers, the timings are tighter than your infrastructure.

    Patroni
    patronictl -c /etc/patroni/patroni.yml edit-config   # ttl, loop_wait, retry_timeout: keep loop_wait + 2*retry_timeout <= ttl

    Look for: Longer ttl means slower failover but fewer false ones. Pick on purpose.

Confirm it is fixed
  1. 6Confirm a stable clusterOnly reads

    Patroni
    patronictl -c /etc/patroni/patroni.yml list

    Look for: One leader, replicas streaming, no new history entries for an hour.

Escalate, or get a second DBA, when
  • More than one failover in an hour.
  • The old primary does not rejoin (see the next playbook).

Get the application team on a call

When
  • Apps did not reconnect after the failover.
Ask them
  • How does your app find the primary: DNS, a VIP, HAProxy, a Kubernetes service?
  • Do your pools test connections and reconnect on errors?
What to suggest, and when it fits
Test connections before usePool settings like testOnBorrow, or a short max lifetime.
Connect with target_session_attrs=read-writeA libpq connection string with all hosts finds the primary itself.
Status update to post
PostgreSQL cluster <name> failed over at <time> from <old> to <new>. Writes failed for <n> seconds. Cause: <what>. Next update <time>.

Done when: One leader for an hour, the old primary back as a replica, and the reason written down.

Don't
  • Leave the cluster paused after the incident.
  • Lower ttl to make failovers faster without knowing your longest normal pause.

Postmortem: so it does not happen again

Prevent it
  • Timings that match your infrastructure, tested with a planned switchover each quarter.
  • Maintenance with patronictl pause or switchover, never by stopping the primary.
Catch it earlier
  • Alert on every leader change, with the reason from the logs.
Automate it
  • An agent can collect the Patroni and kernel logs of the old leader and post the reason within a minute of the failover.

Patroni: the old primary will not rejoin as a replicaAfter a failover, the old primary shows as stopped or start failed, with errors about timelines or missing WAL.Open the playbookClose · 4 steps
You are here if
  • patronictl list shows the member stopped or start failed
  • "requested timeline is not a child of this server's history" in the log

Start here. Do not force it. Let Patroni rewind it, and if that cannot work, rebuild it from the new primary.

Likely causes, most common first
  1. It wrote WAL the new primary never received, so its history diverged. It needs pg_rewind.
  2. use_pg_rewind is off, or pg_rewind cannot run (no wal_log_hints or data checksums).
  3. The WAL it needs to catch up is gone from the new primary.
Confirm and scope
  1. 1See the member and its errorOnly reads

    Patroni
    patronictl -c /etc/patroni/patroni.yml list
    journalctl -u patroni -n 50 | grep -i -E 'timeline|rewind|wal'

    Look for: A timeline or rewind error.

Stop the bleeding, least risky first
  1. 2Let Patroni rewind itLow-risk change

    pg_rewind copies back only the blocks that changed. It needs use_pg_rewind and wal_log_hints or checksums.

    Patroni
    patronictl -c /etc/patroni/patroni.yml edit-config   # postgresql.use_pg_rewind: true
    patronictl -c /etc/patroni/patroni.yml restart <cluster> <member>

    Look for: It starts as a replica on the new timeline.

  2. 3Rebuild it from the leaderRisky: a human decides

    Takes a fresh copy. The writes it had that never reached the new primary are lost: save its data directory first if anyone needs them.

    Patroni
    patronictl -c /etc/patroni/patroni.yml reinit <cluster> <member>

    Look for: It streams again. Time it.

    Undo: None. The old data is replaced.

Confirm it is fixed
  1. 4Confirm it streamsOnly reads

    Patroni
    patronictl -c /etc/patroni/patroni.yml list

    Look for: Running, the new timeline, lag near zero.

Escalate, or get a second DBA, when
  • Someone needs the writes the old primary had that never replicated.

Get the application team on a call

When
  • Writes were lost in the failover.
Ask them
  • Which writes in the last seconds before <time> matter? Can they be replayed from the app or a queue?
What to suggest, and when it fits
Synchronous mode for data that must not be lostPatroni synchronous_mode, accepting slower commits.
Status update to post
The old primary <node> is being rebuilt as a replica. No user impact; failover protection is reduced until it finishes at about <time>.

Done when: Every member streams on the current timeline.

Don't
  • Start the old primary by hand outside Patroni.

Postmortem: so it does not happen again

Prevent it
  • use_pg_rewind on, and data checksums or wal_log_hints on, in every cluster.
Catch it earlier
  • Alert when a member is not streaming for more than 10 minutes.
Automate it
  • Patroni can reinit by itself with remove_data_directory_on_rewind_failure; decide on purpose whether you want that.

InnoDB Cluster (Group Replication and MySQL Router)

IssueWhat you seeWhat we do
Majority of members lostWrites hang, NO_QUORUMProve the others are down, then forceQuorumUsingPartitionOf Playbook →
All members restartedCluster OFFLINErebootClusterFromCompleteOutage on the most advanced member Playbook →
One slow memberPrimary writes slow, applier queue growing on one memberRemove it from the group, fix, add back with clone Playbook →
Huge transactionMember expelled, error about transaction sizeChunk the write; rejoin the member Playbook →
Errant GTIDsMember will not rejoinRemove and re-add with clone Playbook →
Apps bypass RouterWrites fail on the old primary after failoverConnect through Router 6446; restart pools Playbook →
InnoDB Cluster: lost quorum, or every member is downWrites hang or fail across the cluster. MySQL Shell reports the cluster has no quorum, or every member is OFFLINE after a power or network event.Open the playbookClose · 5 steps
You are here if
  • cluster.status() says NO_QUORUM or OFFLINE
  • Writes hang through MySQL Router
  • replication_group_members shows UNREACHABLE members

Start here. Find out which members are truly down and which are only unreachable. Forcing quorum on the wrong side creates two clusters accepting writes.

Likely causes, most common first
  1. A majority of Group Replication members are unreachable, so the rest cannot decide anything and block writes.
  2. All members restarted (power, maintenance, a bad deploy) and Group Replication does not start itself into a new group.
  3. A network split left no side with a majority.
Confirm and scope
  1. 1Cluster and member statusOnly reads

    The Shell view and the server view.

    MySQL
    SELECT MEMBER_HOST, MEMBER_STATE, MEMBER_ROLE FROM performance_schema.replication_group_members;
    MySQL Shell
    mysqlsh --js clusteradmin@<node>:3306 -e "print(dba.getCluster().status({extended: 1}))"

    Look for: Read the states.

Find the cause
  1. 2Make sure the unreachable members are really downOnly reads

    If they are alive on the other side of a network split, forcing quorum here gives you two primaries.

    MySQL Shell
    # on each unreachable host, or through your cloud console:
    systemctl status mysqld
    ping <host>

    Look for: Down for certain: step 3. Alive but cut off: fix the network instead.

Stop the bleeding, least risky first
  1. 3Restore quorum from the surviving membersRisky: a human decides

    Tells the group to continue with only the members you name.

    MySQL Shell
    mysqlsh --js clusteradmin@<node>:3306 -e "dba.getCluster().forceQuorumUsingPartitionOf('<surviving node>:3306')"

    Look for: Writes resume on the surviving primary.

    Undo: Rejoin the other members once they are back (rejoinInstance).

  2. 4Start the cluster after a complete outageRisky: a human decides

    Run it on the member with the most transactions (the most complete GTID set). Shell checks and tells you if another member is ahead.

    MySQL Shell
    mysqlsh --js clusteradmin@<node>:3306 -e "dba.rebootClusterFromCompleteOutage()"

    Look for: The cluster is ONLINE with that member as primary; the others rejoin.

Confirm it is fixed
  1. 5Confirm all members are ONLINEOnly reads

    MySQL
    SELECT MEMBER_HOST, MEMBER_STATE, MEMBER_ROLE FROM performance_schema.replication_group_members;
    MySQL Shell
    mysqlsh --js clusteradmin@<node>:3306 -e "print(dba.getCluster().status())"

    Look for: Status OK, every member ONLINE.

Escalate, or get a second DBA, when
  • You cannot prove the unreachable members are down.
  • Before forceQuorumUsingPartitionOf or rebootClusterFromCompleteOutage: get a second DBA.

Get the application team on a call

When
  • Writes are failing and app owners need a decision on waiting or degrading.
Ask them
  • Can you run read-only? Do you retry writes?
What to suggest, and when it fits
Connect only through MySQL RouterIts read-write port follows the primary.
Status update to post
MySQL cluster <name> lost quorum at <time>; writes are failing. We are <action>. Next update <time>.

Done when: Every member ONLINE, status OK, Router routing writes to the primary.

Don't
  • Force quorum without proving the other side is down.
  • Run rebootClusterFromCompleteOutage on a member that is behind.

Postmortem: so it does not happen again

Prevent it
  • Three or five members across failure zones, never two.
  • group_replication_unreachable_majority_timeout set, so a minority side gives up instead of hanging.
  • group_replication_autorejoin_tries so members come back after short splits.
Catch it earlier
  • Alert on any member not ONLINE, and on the cluster status not OK.
Automate it
  • An agent can run cluster.status() on alert and post which members are where, and whether the missing ones answer ping.

How Group Replication decides: Consensus and leaders.

InnoDB Cluster: a member is in ERROR, expelled, or slowing everyoneOne member shows ERROR, RECOVERING for a long time, or was expelled. Or writes on the primary slowed down because one member falls behind (flow control).Open the playbookClose · 5 steps
You are here if
  • A member not ONLINE in cluster.status()
  • Primary write latency up with low load
  • Errors mentioning errant GTIDs or flow control

Start here. Find out whether the member is slowing the group (remove it fast) or just missing (rejoin it). Then rejoin, or rebuild it with clone.

Likely causes, most common first
  1. A transaction larger than group_replication_transaction_size_limit, or a long apply, got the member expelled.
  2. Errant transactions: something was written directly on a secondary, so its GTIDs no longer match.
  3. One member has a slower disk or CPU, and flow control throttles the whole group to its speed.
  4. The member was down longer than the others kept binlogs for.
Confirm and scope
  1. 1Member states and queuesOnly reads

    Large queues on one member mean it cannot keep up.

    MySQL
    SELECT m.MEMBER_HOST, m.MEMBER_STATE, s.COUNT_TRANSACTIONS_IN_QUEUE AS certify_queue,
           s.COUNT_TRANSACTIONS_REMOTE_IN_APPLIER_QUEUE AS apply_queue
    FROM performance_schema.replication_group_members m
    JOIN performance_schema.replication_group_member_stats s USING (MEMBER_ID);
    MySQL Shell
    mysqlsh --js clusteradmin@<node>:3306 -e "print(dba.getCluster().status({extended: 1}))"

    Look for: Read the states and queues.

Find the cause
  1. 2Read why it leftOnly reads

    The member's error log says expelled, errant GTIDs or a failed recovery.

    MySQL Shell
    grep -i -E 'group_replication|expel|errant|gtid' /var/log/mysqld.log | tail -30

    Look for: Errant GTIDs or missing binlogs: rebuild it (step 4).

Stop the bleeding, least risky first
  1. 3Take the slow member out of the groupRisky: a human decides

    Flow control slows every write to the speed of the slowest member. Removing it restores the primary at once.

    MySQL Shell
    mysqlsh --js clusteradmin@<node>:3306 -e "dba.getCluster().removeInstance('<slow node>:3306', {force: true})"

    Look for: Primary write latency recovers.

    Undo: addInstance it back once its disk or load is fixed.

  2. 4Rejoin it, or rebuild it with cloneLow-risk change

    rejoinInstance for a member that only fell out. Clone replaces its data with a fresh copy when GTIDs do not match.

    MySQL Shell
    mysqlsh --js clusteradmin@<node>:3306 -e "dba.getCluster().rejoinInstance('<node>:3306')"
    # if that fails:
    mysqlsh --js clusteradmin@<node>:3306 -e "var c = dba.getCluster(); c.removeInstance('<node>:3306', {force: true}); c.addInstance('<node>:3306', {recoveryMethod: 'clone'})"

    Look for: The member goes RECOVERING, then ONLINE.

Confirm it is fixed
  1. 5Confirm the group is healthyOnly reads

    MySQL
    SELECT MEMBER_HOST, MEMBER_STATE FROM performance_schema.replication_group_members;

    Look for: Every member ONLINE, queues near zero.

Escalate, or get a second DBA, when
  • Errant transactions exist on more than one member.
  • Removing a member would leave fewer than three.

Get the application team on a call

When
  • A big transaction got a member expelled.
  • Someone wrote directly to a secondary.
Ask them
  • Do you run large batch updates or deletes in one transaction?
  • Does anything connect to the members directly instead of through Router?
What to suggest, and when it fits
Chunk big writesStay well under the transaction size limit (150 MB by default).
Only connect through RouterAnd keep super_read_only on secondaries (InnoDB Cluster sets it).
Status update to post
One member of MySQL cluster <name> is <out / slow>. <Writes are affected / not affected.> We are <action>. Next update <time>.

Done when: Every member ONLINE with empty queues.

Don't
  • Write to a secondary to "fix" data.
  • Reset GTIDs by hand to make a member rejoin.

Postmortem: so it does not happen again

Prevent it
  • Members with the same instance and disk types.
  • Big writes in chunks.
Catch it earlier
  • Alert on applier queue size per member and on any member not ONLINE.
Automate it
  • An agent can spot a growing applier queue on one member and propose removing it before flow control hurts the primary.

InnoDB Cluster: the database failed over, but the apps did notcluster.status() is OK with a new primary, but apps still fail writes or cannot connect.Open the playbookClose · 4 steps
You are here if
  • Writes fail with read-only errors after a failover
  • Router log errors about metadata

Start here. Check what the apps connect to, then what Router thinks the primary is.

Likely causes, most common first
  1. Apps connect to a member directly instead of through MySQL Router.
  2. Router cannot read the cluster metadata (its user, network or a stale metadata cache).
  3. Apps use the read-only port for writes, or connection pools keep connections to the old primary.
Confirm and scope
  1. 1List the routers and their viewOnly reads

    MySQL Router
    mysqlsh --js clusteradmin@<node>:3306 -e "print(dba.getCluster().listRouters())"
    tail -50 /var/log/mysqlrouter/mysqlrouter.log

    Look for: Errors fetching metadata, or a router that has not checked in recently.

Find the cause
  1. 2Check which port the app usesOnly reads

    Router listens on 6446 for read-write and 6447 for read-only by default (classic protocol).

    MySQL
    SELECT user, SUBSTRING_INDEX(host, ':', 1) AS client, count(*)
    FROM information_schema.processlist GROUP BY 1, 2 ORDER BY 3 DESC;

    Look for: Apps connected straight to the old primary's address bypass Router.

Stop the bleeding, least risky first
  1. 3Restart Router, or the app poolsLow-risk change

    A restart makes Router reload metadata. Restarting app pods clears pools holding old connections.

    MySQL Router
    systemctl restart mysqlrouter
    # or restart the app instances whose pools hold old connections

    Look for: Writes succeed through 6446.

Confirm it is fixed
  1. 4Confirm writes go to the new primaryOnly reads

    MySQL
    SELECT @@hostname, @@read_only, @@super_read_only;

    Look for: Through port 6446 this returns the primary with read_only = 0.

Escalate, or get a second DBA, when
  • Apps hardcode member addresses.

Get the application team on a call

When
  • Any app connects to a member directly.
Ask them
  • What host and port does your connection string use?
  • Do pools validate connections?
What to suggest, and when it fits
Router on each app host, or as a sidecarApps connect to localhost:6446.
Short connection lifetimesSo pools pick up the new primary.
Status update to post
MySQL cluster <name> failed over to <node>. The database is healthy; <apps> are still pointed at the old primary and we are restarting their connections.

Done when: All apps write through Router to the new primary.

Don't
  • Make the old primary writable again to "help" the apps.

Postmortem: so it does not happen again

Prevent it
  • All app connections through Router, checked in config review.
Catch it earlier
  • Alert on write errors with "read-only" after a primary change.
Automate it
  • A post-failover check that lists clients still connected to the old primary.

MongoDB replica set

IssueWhat you seeWhat we do
Majority of voters downNo PRIMARY, NotWritablePrimary errorsBring members back; force reconfig only as last resort Playbook →
Network flapsElections every few minutesFix the network; check heartbeats and an overloaded primary Playbook →
PSA with the secondary downMajority writes hang, cache pressure on the primarySet the down member to votes 0, priority 0 Playbook →
Member down too longToo stale to catch upInitial sync; a larger oplog Playbook →
w: 1 writes before a failoverRollback files on the old primary, writes missingw: majority for data that matters Playbook →
MongoDB replica set: no primary, or elections keep happeningWrites fail with "not primary" or NotWritablePrimary errors. rs.status() shows no PRIMARY, or the primary changes every few minutes.Open the playbookClose · 5 steps
You are here if
  • NotWritablePrimary errors in apps
  • rs.status() without a PRIMARY
  • Log lines "Starting an election" repeating

Start here. Count the healthy voting members against the majority. With a majority, the set elects by itself; without one, you either bring members back or force a reconfig, which can lose writes.

Likely causes, most common first
  1. A majority of voting members are down or unreachable.
  2. Network flaps between members, so heartbeats miss and elections start.
  3. An overloaded primary misses heartbeats.
  4. A PSA set (primary, secondary, arbiter) lost its secondary and is struggling.
Confirm and scope
  1. 1Who is up, and who votesOnly reads

    MongoDB
    rs.status().members.map(m => [m.name, m.stateStr, m.health, m.lastHeartbeatMessage])
    rs.conf().members.map(m => [m.host, m.votes, m.priority, m.arbiterOnly])

    Look for: Count healthy voters against the total.

Find the cause
  1. 2Why elections keep happeningOnly reads

    The logs say which member called the election and why.

    mongosh
    grep -E 'Starting an election|stepping down|heartbeat' /var/log/mongodb/mongod.log | tail -30

    Look for: Heartbeat timeouts point at the network or an overloaded primary (see CPU at 100%).

Stop the bleeding, least risky first
  1. 3Bring members backLow-risk changeTime box: 15 minutes

    The safe fix: start them, fix the network. The set elects a primary by itself once a majority sees each other.

    mongosh
    systemctl status mongod
    systemctl start mongod

    Look for: A PRIMARY appears within seconds of a majority.

  2. 4Last resort: force a reconfig with the members you haveRisky: a human decides

    Run on a healthy secondary. It drops the missing members from the config so the rest can elect. Writes the old primary had that never replicated will be rolled back later.

    MongoDB
    cfg = rs.conf()
    cfg.members = cfg.members.filter(m => ['<host1>:27017', '<host2>:27017'].includes(m.host))
    rs.reconfig(cfg, { force: true })

    Look for: One PRIMARY. Add the others back when they return.

    Undo: Reconfig again to add the members back once they are healthy.

Confirm it is fixed
  1. 5Confirm one stable primaryOnly reads

    MongoDB
    rs.status().members.map(m => [m.name, m.stateStr])

    Look for: One PRIMARY, no new elections for an hour.

Escalate, or get a second DBA, when
  • Forcing a reconfig.
  • More than one member thinks it is primary.

Get the application team on a call

When
  • Writes are failing and apps need to know whether to retry.
Ask them
  • Which write concern do you use: w: 1 or majority?
  • Do your drivers have retryable writes on?
What to suggest, and when it fits
w: majority for data that mattersWrites acknowledged by a majority are not rolled back in a failover.
retryWrites=trueDrivers retry once across a failover.
Status update to post
MongoDB replica set <name> has no primary since <time>; writes fail. We are <action>. Next update <time>.

Done when: One primary for an hour, every member healthy.

Don't
  • Force a reconfig while the old primary might still be taking writes.
  • Add an arbiter to "fix" an even member count when you could add a data-bearing member.

Postmortem: so it does not happen again

Prevent it
  • Three data-bearing members across zones (PSS), not an arbiter.
  • Members on the same instance type; priorities set on purpose.
Catch it earlier
  • Alert on no primary, and on more than one election an hour.
Automate it
  • An agent can count voters and healthy members on alert and say whether the set can elect by itself.

Elections and majorities: CAP as settings you choose.

MongoDB replica set: a member is stale, or majority writes hangA secondary is stuck in RECOVERING, or "too stale to catch up". Or writes with w: majority hang while w: 1 writes work.Open the playbookClose · 5 steps
You are here if
  • A member in RECOVERING for a long time
  • "too stale to catch up" in the log
  • Majority writes time out

Start here. Check the oplog window against how long the member was gone, and whether a majority of data-bearing members is up for majority writes.

Likely causes, most common first
  1. The secondary was down longer than the oplog window, so the entries it needs are gone.
  2. In a PSA set with the secondary down, the majority commit point cannot move, majority writes wait and cache pressure grows on the primary.
  3. A secondary is too slow to apply, on a slower disk or busy with reads.
Confirm and scope
  1. 1Member states and oplog windowOnly reads

    MongoDB
    rs.printReplicationInfo()            // the oplog window on this member
    rs.printSecondaryReplicationInfo()
    rs.status().members.map(m => [m.name, m.stateStr, m.optimeDate])

    Look for: Read the states.

Stop the bleeding, least risky first
  1. 2Stop counting the down memberRisky: a human decides

    In a PSA set, set the unavailable secondary to votes 0 and priority 0. The majority then forms without it and majority writes flow.

    MongoDB
    cfg = rs.conf()
    m = cfg.members.find(x => x.host === '<down host>:27017')
    m.votes = 0; m.priority = 0
    rs.reconfig(cfg)

    Look for: Majority writes succeed again.

    Undo: Set votes and priority back once the member has caught up.

  2. 3Resync the stale memberLow-risk change

    Stop it, empty its data directory, start it: it runs an initial sync from another member.

    mongosh
    systemctl stop mongod
    mv /var/lib/mongodb /var/lib/mongodb.old && mkdir /var/lib/mongodb && chown mongodb: /var/lib/mongodb
    systemctl start mongod

    Look for: It goes STARTUP2, then SECONDARY. Initial sync on a big set takes hours.

  3. 4Give the oplog a longer windowLow-risk change

    So a member can be down longer next time.

    MongoDB
    db.adminCommand({ replSetResizeOplog: 1, size: <megabytes> })   // on each member

    Look for: rs.printReplicationInfo() shows a longer window.

Confirm it is fixed
  1. 5Confirm every member is SECONDARY or PRIMARYOnly reads

    MongoDB
    rs.status().members.map(m => [m.name, m.stateStr])
Escalate, or get a second DBA, when
  • Reconfiguring votes.
  • Initial sync will take longer than the remaining members can be trusted alone.

Get the application team on a call

When
  • Majority writes hang.
Ask them
  • Which collections need w: majority, and which could accept w: 1 for an hour?
What to suggest, and when it fits
Three data-bearing membersSo one down member never blocks majority writes.
Status update to post
MongoDB replica set <name>: member <host> is <stale / down>. <Majority writes are affected / not affected.> We are <action>.

Done when: Every member healthy and a comfortable oplog window.

Don't
  • Delete a member's data while it is the only healthy secondary.

Postmortem: so it does not happen again

Prevent it
  • An oplog window of days, not hours.
  • PSS instead of PSA.
Catch it earlier
  • Alert when the oplog window drops below a threshold, and on members not SECONDARY.
Automate it
  • An agent can compare each member's lag with the oplog window and warn before a member goes stale.

RDS, Aurora and Kubernetes

IssueWhat you seeWhat we do
Multi-AZ failoverA minute or two of errors, same endpointRead RDS events; restart pools that did not follow Playbook →
JVM caches DNSErrors long after the failover completedShort DNS TTL, RDS Proxy or the AWS JDBC wrapper Playbook →
Burstable instance out of CPU creditsSlow everything in Standard mode, CPU capped to baseline; surplus-credit charges in Unlimited modeMove off t-class, or check the credit mode Playbook →
Storage full on RDSInstance in storage-full, writes stopModify allocated storage; turn on autoscaling Playbook →
Liveness probe kills a busy databaseCrashLoopBackOff under load or during recoveryLenient liveness, a startupProbe Playbook →
Memory settings sized for the nodeOOMKilled, exit code 137Fit buffers to the container limit Playbook →
Volume pinned to one zonePod Pending after a node lossCapacity in that zone; never delete the PVC Playbook →
RDS or Aurora: a failover happened, or the instance is unavailableA burst of connection errors, then the database is back with the same endpoint. Or the instance status is not "available".Open the playbookClose · 5 steps
You are here if
  • RDS event: "Multi-AZ instance failover started/completed"
  • Connection errors for one or two minutes
  • Instance status other than available

Start here. Read the RDS events first: they tell you what AWS did and when. Then make sure the apps followed the endpoint.

Likely causes, most common first
  1. A Multi-AZ failover: host failure, maintenance, an instance class change, or a reboot with failover.
  2. Aurora promoted a reader after the writer failed.
  3. The instance is in storage-full, incompatible-parameters or rebooting.
  4. Apps cached the old IP from DNS and keep failing after the failover finished.
Confirm and scope
  1. 1What AWS didOnly reads

    AWS CLI
    aws rds describe-events --source-type db-instance --source-identifier <id> --duration 180
    aws rds describe-db-instances --db-instance-identifier <id> --query 'DBInstances[0].[DBInstanceStatus,AvailabilityZone,SecondaryAvailabilityZone]'

    Look for: A failover with its reason, or a status such as storage-full.

    • If status is storage-full → See The disk is filling up: modify the allocated storage.
  2. 2Aurora: who is the writer nowOnly reads

    AWS CLI
    aws rds describe-db-clusters --db-cluster-identifier <cluster> --query 'DBClusters[0].DBClusterMembers'

    Look for: The member with IsClusterWriter true.

Find the cause
  1. 3Did the apps follow the endpoint?Only reads

    The endpoint name moved; apps that cached the IP, or pools with old connections, keep failing.

    AWS CLI
    dig +short <endpoint>   # should resolve to the new writer

    Look for: Errors continue after the event says completed: restart the app pools.

Stop the bleeding, least risky first
  1. 4Restart the stuck app poolsLow-risk change

    AWS CLI
    kubectl rollout restart deployment/<app> -n <ns>

    Look for: Errors stop.

Confirm it is fixed
  1. 5Confirm available and writableOnly reads

    AWS CLI
    aws rds describe-db-instances --db-instance-identifier <id> --query 'DBInstances[0].DBInstanceStatus'

    Look for: available, and the apps' error rates are back to normal.

Escalate, or get a second DBA, when
  • The instance is not available after 15 minutes: open an AWS support case at the right severity.

Get the application team on a call

When
  • Apps kept failing after the failover completed.
Ask them
  • Does your runtime cache DNS (the JVM does by default)?
  • Do pools validate connections?
What to suggest, and when it fits
RDS ProxyIt keeps app connections open through a failover.
A short DNS TTL in the runtimeFor the JVM, networkaddress.cache.ttl of a few seconds.
The AWS Advanced JDBC WrapperIt knows the Aurora topology and fails over faster than DNS.
Status update to post
Database <name> on RDS failed over at <time> (<reason from the event>). It is available again. <Apps> are <reconnected / being restarted>.

Done when: Available, the apps reconnected, and the reason from the event written down.

Don't
  • Reboot with failover again to "fix" apps that did not reconnect. Fix the apps.

Postmortem: so it does not happen again

Prevent it
  • RDS Proxy or a topology-aware driver for critical apps.
  • Maintenance windows set to quiet hours, and reviewed pending maintenance.
Catch it earlier
  • Subscribe to RDS event notifications for failover, low storage and maintenance.
Automate it
  • An agent can read the events on any connection-error alert and post what AWS did.

Kubernetes: the database pod keeps restarting, or will not startThe database pod is in CrashLoopBackOff, keeps restarting, is Pending, or its status shows OOMKilled.Open the playbookClose · 5 steps
You are here if
  • Restarts count going up
  • CrashLoopBackOff or OOMKilled
  • Pod Pending

Start here. Read why the last container ended before changing anything. A probe kill and an OOM kill look the same from the app and need opposite fixes.

Likely causes, most common first
  1. A liveness probe that times out while the database is busy, so Kubernetes kills a healthy database again and again.
  2. The container memory limit is smaller than what the database is configured to use.
  3. The volume is full.
  4. The pod cannot be scheduled: its volume is in another zone, or no node has room.
Confirm and scope
  1. 1Why did it stop?Only reads

    kubectl
    kubectl get pod <db-pod> -n <ns> -o wide
    kubectl describe pod <db-pod> -n <ns> | grep -A8 -E 'Last State|Events'
    kubectl logs <db-pod> -n <ns> --previous | tail -40

    Look for: Read the reason.

Find the cause
  1. 2Why it will not scheduleOnly reads

    kubectl
    kubectl describe pod <db-pod> -n <ns> | grep -A10 Events
    kubectl get pvc -n <ns>
    kubectl get pv <pv> -o jsonpath='{.spec.nodeAffinity}'

    Look for: A volume pinned to a zone with no free node: add capacity in that zone. Do not delete the PVC.

Stop the bleeding, least risky first
  1. 3Stop the probe from killing a busy databaseLow-risk change

    A database replaying its log or under heavy load can miss a short probe. Give it a longer timeout, or a startupProbe for crash recovery.

    kubectl
    kubectl edit <operator resource or statefulset> -n <ns>
    # livenessProbe: timeoutSeconds 10+, failureThreshold 6+; add a startupProbe for recovery

    Look for: Restarts stop climbing.

  2. 4Fit memory to the containerLow-risk change

    Either raise the limit, or lower the database's memory settings so they fit inside it.

    kubectl
    kubectl get pod <db-pod> -n <ns> -o jsonpath='{.spec.containers[*].resources.limits.memory}'
    # then change the limit or the database settings in the operator's resource

    Look for: No more OOMKilled through a peak.

Confirm it is fixed
  1. 5Confirm the pod is Ready and the cluster healthyOnly reads

    kubectl
    kubectl get pods -n <ns>
    kubectl cnpg status <cluster> -n <ns>    # or the operator's equivalent

    Look for: Ready, no new restarts for an hour, replicas healthy.

Escalate, or get a second DBA, when
  • The operator itself is failing to reconcile.
  • Anyone suggests deleting the PVC or the StatefulSet.

Get the application team on a call

When
  • The platform team owns the probes, limits or nodes.
Ask them
  • Who owns this operator and its resource? Which change went out last?
  • Is there a PodDisruptionBudget, and did a node drain move the pod?
What to suggest, and when it fits
Database-aware probesReadiness checks the role; liveness is lenient; startupProbe covers recovery.
A PodDisruptionBudgetSo node drains never take two members at once.
Guaranteed QoS for databasesRequests equal to limits for memory.
Status update to post
Database <name> on Kubernetes is restarting because <reason>. <Impact>. We are <action>. Next update <time>.

Done when: The pod is Ready with no new restarts for an hour.

Don't
  • Delete the PVC or the StatefulSet to "start fresh".
  • Edit config inside the pod: the operator replaces it.

Postmortem: so it does not happen again

Prevent it
  • Probe settings reviewed for every database, with recovery time in mind.
  • Memory settings derived from the container limit, not the node.
  • PodDisruptionBudgets for every database cluster.
Catch it earlier
  • Alert on database pod restarts, OOMKilled and Pending.
Automate it
  • An agent can run describe and logs --previous on any database pod restart and post the reason.

Other engines

Redis, Cassandra and vector search

Redis: latency spikes, memory full, writes refusedCommands that took a millisecond take tens or hundreds. Or writes fail with "OOM command not allowed when used memory > maxmemory".Open the playbookClose · 6 steps
You are here if
  • Latency alert on Redis or on the app endpoints that use it
  • "OOM command not allowed" errors
  • Many client timeouts at once

Start here. Redis runs one command at a time, so one slow command or a full memory affects everyone. Check memory and the slow log, then find the client causing it.

Likely causes, most common first
  1. Memory reached maxmemory, and the eviction policy is noeviction.
  2. One big key: a list, set or hash with millions of members, read or deleted in one command.
  3. A fork for a snapshot or rewrite on a large dataset pauses the server.
  4. A slow command such as KEYS, or a Lua script that runs long.
Confirm and scope
  1. 1Check memory against the limitOnly reads

    Writes are refused when memory hits maxmemory with noeviction.

    redis-cli
    redis-cli INFO memory | grep -E 'used_memory_human|maxmemory_human|maxmemory_policy|mem_fragmentation_ratio'
    redis-cli INFO stats | grep -E 'evicted_keys|rejected_connections'

    Look for: Near the limit: step 5.

Find the cause
  1. 2Find the slow commandsOnly reads

    One slow command delays every client.

    redis-cli
    redis-cli SLOWLOG GET 10
    redis-cli --latency            # live latency from this client
    redis-cli LATENCY DOCTOR       # needs latency-monitor-threshold set

    Look for: KEYS, big SMEMBERS or HGETALL, or a long script.

  2. 3Find the client sending itOnly reads

    CLIENT LIST shows each connection's last command and its address.

    redis-cli
    redis-cli CLIENT LIST | grep -E 'cmd=(keys|smembers|hgetall|eval)'
    # each line has id=, addr= and name=: the address tells you which app

    Look for: Note the address and name. That is the team to call.

  3. 4Find big keysOnly reads

    One key with millions of members makes every command on it slow.

    redis-cli
    redis-cli --bigkeys     # scans with SCAN; run it on a replica if you can
    redis-cli --memkeys
    redis-cli MEMORY USAGE <key>

    Look for: Split it in the app; delete with UNLINK.

Stop the bleeding, least risky first
  1. 5Stop the bleedingLow-risk change

    For a cache, let Redis evict. Remove the big key without blocking, and disconnect the client running KEYS.

    redis-cli
    redis-cli CONFIG SET maxmemory-policy allkeys-lru   # only if every key can be rebuilt
    redis-cli UNLINK <big key>
    redis-cli CONFIG REWRITE                            # keep the change after a restart
    redis-cli CLIENT KILL ID <id>

    Look for: Writes succeed and latency falls.

    Undo: CONFIG SET maxmemory-policy <old policy>

Confirm it is fixed
  1. 6Confirm latency is backOnly reads

    p99 back to normal, memory below the limit.

    redis-cli
    redis-cli SLOWLOG GET 10
    redis-cli --latency            # live latency from this client
    redis-cli LATENCY DOCTOR       # needs latency-monitor-threshold set
What changes on your platform
On RDS or Aurora
  • ElastiCache: DatabaseMemoryUsagePercentage, EngineCPUUtilization (the one thread), Evictions and CurrConnections in CloudWatch. KEYS and CONFIG may be renamed or blocked; change settings in the parameter group.
On Kubernetes
  • A Redis pod with persistence on a slow volume pauses on every fork for a snapshot. A cache usually needs no persistence at all.
Escalate, or get a second DBA, when
  • Redis holds data that cannot be rebuilt (sessions, queues) and memory is full.
  • A failover happened and clients did not follow.

Get the application team on a call

When
  • One client sends slow commands or builds big keys.
  • Memory grew because of a new use.
Ask them
  • What do you store, how big does a key get, and does it need a TTL?
  • Can this data be rebuilt from the database if Redis loses it?
What to suggest, and when it fits
TTL on every cache keySo memory cannot fill with keys nobody reads.
Split big keysMany small hashes instead of one huge one.
SCAN instead of KEYSNever KEYS in production code.
A separate Redis for data you cannot loseDo not mix cache and queues in one instance.
Status update to post
Redis <name>: <slow / refusing writes>. Cause: <what>. We are <action>. Next update <time>.

Done when: Latency is normal, memory is below the limit, and the key or client that caused it has an owner and a fix.

Don't
  • Run KEYS * in production. It blocks Redis until it has walked every key.
  • Set an evicting policy on a Redis that holds data nobody can rebuild.

Postmortem: so it does not happen again

Prevent it
  • TTL on cache keys, and the right eviction policy for each instance.
  • Rename or disable KEYS and FLUSHALL in production.
Catch it earlier
  • Alert on memory at 80 percent of maxmemory, and on evicted keys when they should not happen.
  • Alert on slowlog entries.
Automate it
  • An agent can sample big keys weekly on a replica and report the owners.

How Redis works and where it breaks: Redis, the cache in front.

Cassandra: slow reads on some nodes, deleted data returningReads are slow or time out on some nodes but not others. Or rows that were deleted show up again.Open the playbookClose · 7 steps
You are here if
  • Read latency p99 up on some nodes
  • Read timeouts in the app
  • Tombstone warnings in system.log

Start here. With replication factor 3, one sick node should not be an outage. Find it, take client traffic off it, then fix the table that makes it sick.

Likely causes, most common first
  1. A partition grew far too large.
  2. Reads scan many tombstones before finding live data.
  3. Compaction is behind, so each read touches many SSTables.
  4. Repair did not run within gc_grace_seconds.
Confirm and scope
  1. 1Find the sick nodesOnly reads

    Pending reads and dropped messages show which nodes are struggling.

    nodetool and logs
    nodetool status          # every node should be UN (up, normal)
    nodetool tpstats         # Pending and Blocked tasks, and dropped messages

    Look for: One or two nodes stand out: step 2.

Find the cause
  1. 2Look at the table the slow reads hitOnly reads

    Partition size and SSTables per read.

    nodetool and logs
    nodetool tablehistograms <keyspace> <table>   # partition size and SSTables per read
    nodetool tablestats <keyspace>.<table>          # max partition bytes, tombstones per slice

    Look for: Huge partitions or many SSTables per read.

  2. 3Check tombstonesOnly reads

    Deletes and TTLs pile up.

    nodetool and logs
    grep -i tombstone /var/log/cassandra/system.log | tail -20

    Look for: A data model problem: get the app team on the call.

  3. 4Check compaction and GCOnly reads

    Behind on compaction, or long GC pauses.

    nodetool and logs
    nodetool compactionstats    # pending tasks
    nodetool gcstats
    grep GCInspector /var/log/cassandra/system.log | tail -10
Stop the bleeding, least risky first
  1. 5Take client traffic off the sick nodeLow-risk change

    The other replicas serve the reads. The node keeps receiving writes and catches up.

    nodetool and logs
    nodetool disablebinary    # stop serving CQL clients on this node
    # later: nodetool enablebinary

    Look for: Read latency falls for clients.

    Undo: nodetool enablebinary

  2. 6Deleted data returning: repairLow-risk change

    A replica missed a delete.

    nodetool and logs
    nodetool repair -pr <keyspace>    # on every node in turn, primary ranges only

    Look for: Schedule repair within gc_grace_seconds.

Confirm it is fixed
  1. 7Confirm latency is even across nodesOnly reads

    Then put the node back.

    nodetool and logs
    nodetool enablebinary
    nodetool tpstats
What changes on your platform
On Kubernetes
  • With K8ssandra or another operator, run nodetool inside the pod, and let the operator do restarts and repairs (Reaper).
    kubectl exec -it <cassandra-pod> -n <ns> -c cassandra -- nodetool status
Escalate, or get a second DBA, when
  • More than one replica of the same range is sick.
  • Deleted data reappeared in a table that matters (payments, permissions).

Get the application team on a call

When
  • A partition is too large or full of tombstones: that is the data model.
Ask them
  • What is the partition key, and how big can one partition grow?
  • Do you delete or overwrite with nulls a lot? Use TTLs?
  • Which query is slow, and does it read a whole partition?
What to suggest, and when it fits
Bucket the partition keyAdd a time bucket so no partition grows past ~100 MB.
Avoid nulls and mass deletesThey write tombstones.
Use TTLs with time-window compactionFor time series.
Status update to post
Cassandra <cluster>: reads are slow on <nodes>. We have taken them out of client traffic. Cause: <what>. Next update <time>.

Done when: Latency is even across nodes, every node is serving again, and the table has a fix planned.

Don't
  • Lower gc_grace_seconds below how often repair runs.
  • Restart the slow node and hope. It comes back with the same partitions.

Postmortem: so it does not happen again

Prevent it
  • Partition size limits in design review.
  • Repair on a schedule with a tool such as Cassandra Reaper.
Catch it earlier
  • Alert on max partition size, tombstones per read and pending compactions.
Automate it
  • An agent can check repair history against gc_grace_seconds for every table and open tickets.

How Cassandra spreads data and where it breaks: Cassandra, built to spread. A real case: Discord's 20 second channel.

Vector search: results missing, or search got slowSimilar items that should be found are not, or a filtered search returns fewer results than asked for. Or search latency grew with the data.Open the playbookClose · 6 steps
You are here if
  • Users report missing results, or an AI feature gives worse answers
  • Search latency up after data growth
  • Filtered searches return fewer rows than LIMIT

Start here. Measure recall against an exact search on a real query first. "The answers got worse" is not a database finding until you have that number. Commands are for pgvector.

Likely causes, most common first
  1. A filter applied after the approximate index.
  2. Search settings too low for the data size.
  3. The index no longer fits in memory.
  4. An IVFFlat index built on early data.
Confirm and scope
  1. 1Compare the index with an exact searchOnly reads

    Recall is how many true nearest neighbours the index found.

    PostgreSQL with pgvector
    -- approximate, using the index
    SELECT id FROM items ORDER BY embedding <=> :q LIMIT 10;
    -- exact, without the index
    BEGIN;
    SET LOCAL enable_indexscan = off;
    SELECT id FROM items ORDER BY embedding <=> :q LIMIT 10;
    COMMIT;

    Look for: 9 or 10 of 10 is good.

Find the cause
  1. 2Does a filter run after the index?Only reads

    The index returns its candidates, then the filter throws most away.

    PostgreSQL with pgvector
    EXPLAIN ANALYZE
    SELECT id FROM items WHERE tenant_id = 7
    ORDER BY embedding <=> :q LIMIT 10;
    -- an index scan, then Filter with many Rows Removed

    Look for: Many rows removed by the filter.

  2. 3Does the index fit in memory?Only reads

    From disk, every hop in the graph is a read.

    PostgreSQL with pgvector
    SELECT pg_size_pretty(pg_relation_size('items_embedding_idx'));
    SHOW shared_buffers;

    Look for: Much bigger than memory: more RAM, halfvec, or partitions.

Stop the bleeding, least risky first
  1. 4Fix the filterLow-risk change

    Let the index keep scanning, or give the big tenant its own index.

    PostgreSQL with pgvector
    -- pgvector 0.8 and later: keep scanning until LIMIT rows pass the filter
    SET hnsw.iterative_scan = relaxed_order;
    -- or a partial index for a big tenant
    CREATE INDEX CONCURRENTLY items_t7_emb ON items
      USING hnsw (embedding vector_cosine_ops) WHERE tenant_id = 7;

    Look for: The filtered query returns the full LIMIT.

  2. 5Raise the search settingsLow-risk change

    More of the graph searched, more true neighbours found.

    PostgreSQL with pgvector
    SET hnsw.ef_search = 100;       -- default 40; must be at least LIMIT
    SET ivfflat.probes = 10;        -- default 1

    Look for: Recall up and latency acceptable.

    Undo: RESET hnsw.ef_search;

Confirm it is fixed
  1. 6Confirm recall on several real queriesOnly reads

    One query is not a test.

    PostgreSQL with pgvector
    -- approximate, using the index
    SELECT id FROM items ORDER BY embedding <=> :q LIMIT 10;
    -- exact, without the index
    BEGIN;
    SET LOCAL enable_indexscan = off;
    SELECT id FROM items ORDER BY embedding <=> :q LIMIT 10;
    COMMIT;
What changes on your platform
On RDS or Aurora
  • pgvector is available on RDS and Aurora PostgreSQL. HNSW indexes need memory: check FreeableMemory and BufferCacheHitRatio when latency rises.
On Kubernetes
  • Index builds need maintenance_work_mem inside the container limit. A big HNSW build can get the pod OOMKilled.
Escalate, or get a second DBA, when
  • The index must be rebuilt on a large table.
  • The fix needs more memory.

Get the application team on a call

When
  • Results got worse for one tenant or one filter.
  • The data grew much faster than planned.
Ask them
  • Which queries got worse? Can you give five real examples?
  • Do you filter by tenant, date or category before or after the vector search?
  • How many vectors per tenant, and how fast is it growing?
What to suggest, and when it fits
A partial index per large tenantOr partitions by tenant.
Iterative scanspgvector 0.8 and later.
A recall test in CIA fixed set of queries with known answers, run on every change.
Status update to post
<feature> search is <missing results / slow>. Cause: <what>. We are <action>. Next update <time>.

Done when: Recall on real queries is back where you want it, and filtered searches return the full number of results.

Don't
  • Trust a vector search that has never been compared with an exact search on your data.
  • Raise ef_search for everyone to fix one tenant's filter.

Postmortem: so it does not happen again

Prevent it
  • A recall test on a fixed query set, run weekly and on every index change.
  • Index memory sized with the data growth.
Catch it earlier
  • Track recall and p95 latency for a fixed query set.
Automate it
  • An agent can run the recall test nightly and flag drops.

How vector indexes work: Vector databases. Measured (lab run Nov 19, 2026): a tenant filter after HNSW returned 1.3 rows instead of 10.

To practise before it is real, work through On call tonight.

For automation, and for a future DBA agent. Every step is labelled: Only reads steps can run without asking; Low-risk change steps are proposed with the evidence and run after one person approves; Risky steps are prepared and explained, and a human decides. The same playbooks are published as data: runbooks.json.
After it is fixed

Three things I do once it is quiet

  1. Write down what you saw, what you ran and what fixed it, while it is fresh. The commands that helped become the start of a runbook.
  2. Add the alert that would have caught it earlier: connections at 80% of the limit, lag over a threshold, disk at 75%, the oldest transaction older than an hour.
  3. Fix the cause, not only the symptom: the missing index, the pool size, the slot nobody reads.
Connected

Where this shows up

The same mechanism, old row versions, vacuum and long transactions, replication and failover, indexes and plans, elsewhere on the site: in real incidents, in measurements, and in designs.

Part 4 of 4 · Operate · 15 pagesAll pages

How do I run it in production? What to check when it is slow or broken, where it runs and what it costs, how big it must be, pooling, backups, security, upgrades and other changes made safely.