Can I break this?: Writing resilient “save” methods
summary
A concrete claim: improbable failures happen often enough to cost real money—one example is a job that charged a customer 12 times—so extract the persistence into a single save method and ask “can I break this.” Use ActiveRecord transactions and row locks to avoid partial writes, push side effects into a database-backed queue or outbox, and make async retries safe with an item potency key. The patterns produce a transactionally “green” save and prevent duplicate charges.
AI-written summary · about
chapters (4)
related talks
34mThe Very Hungry Transaction
33mThe Very Hungry Transaction
29mPutting Rails in a corner: Understanding database isolation
35mBeyond Validates_Presence_of: Ensuring Eventual Consistency
41m(Re)Building a large scale payments system on Rails
34mToo Big to Fail
44mElixir and money
42mA Race To The Bottom: Database Transactions Undermining Your AppSec
