Skip to content

Alerting checklist

Six numbers cover most transaction incidents on this site. Every one is queryable with plain SQL, every mechanism behind them is proven by a scenario in the chapters above.

#AlertQuery sourceBacked by
1Oldest transaction age > minutesmin(trx_started) in information_schema.innodb_trxfind-long-transactions
2Idle-in-transaction sessions > secondsinnodb_trx ⋈ processlist command = 'Sleep'find-long-transactions
3Lock waits nowrows in sys.innodb_lock_waitswho-is-blocking-whom
4Deadlock rateΔ lock_deadlocks (INNODB_METRICS)deadlock-counter
5Lock-timeout rateΔ lock_timeouts (INNODB_METRICS)lock timeouts
6Purge backlog sustainedtrx_rseg_history_len (INNODB_METRICS)history-list-health

Reading the board:

  • 1, 2, and 6 firing together is one forgotten transaction: alert 2's join names it, so kill it or fix the code path and the other alerts drain on their own.
  • 3 spiking while 1 stays quiet is hot-row contention, not a stuck session — look at lock queues and whether a SKIP LOCKED or atomic-update shape fits.
  • 4 climbing steadily points at lock ordering first (deadlock avoidance), then gap locks if the statements involve ranges or inserts, and every consumer wants the retry loop.
  • 5 without 4 means the waits are long but acyclic — usually one slow writer everyone queues behind, and alert 3's view names it.

What's deliberately not here: anomaly detection for lost updates and write skew. No counter sees them — they look like successful transactions. They're prevented by code patterns, caught by application-level invariant checks, and that's precisely why the patterns chapter exists.

Further reading

MIT Licensed · Every transcript on this site was generated by a real database run against MySQL 8.4.10 and PostgreSQL 18.4 at bd6f201, and re-proven through psycopg and PyMySQL.