The Very Hungry Transaction
summary
Shows concrete failures and fixes: Rails ActiveRecord save opens a transaction that can deadlock without an index on SKU, thousands-item orders create hundreds or thousands of locks, external HTTP calls (fulfillment) or queueing jobs inside a transaction exhaust DB connections, and after_create enqueues jobs too early — use after_create_commit instead. Demonstrates measurable thresholds (hundreds vs thousands of records, seconds of transaction time), tooling (Rails 7.2 callbacks, isolator gem, DB performance schema) and practical fixes that make the system work again.
AI-written summary · about
chapters (10)
- 0:00Introduction
- 1:52Growing transaction problem
- 4:00Lock contention
- 8:39Slow transactions cause failures
- 11:09Move work out of transactions
- 15:22External calls in transactions
- 21:35Database overload
- 24:49Split transactions across DBs
- 27:57Risks of massive transactions
- 30:45Writing safe transactions
related talks
34mThe Very Hungry Transaction
32mThe Very Hungry Transaction
34mThe Very Hungry Transaction
20mCRUD! The Consequences of Not Understanding How ActiveRecord ...
29mPutting Rails in a corner: Understanding database isolation
40mrails db:migrate:safely
42mA Race To The Bottom: Database Transactions Undermining Your AppSec
36mRails: Shadow Facets of Concurrency
