Off to the races
summary
Claim: Rails apps lose increments when two requests do a read modify write on the same row, exemplified by an ideas voting counter that drops votes. Reproducers: add sleeps, use a redis flag to stall one process, or use rspec and wrap original to load an out‑of‑date record. Fixes shown: use atomic operations (SQL increment or redis INCR), optimistic locking via lock_version (raises active record stale object error), pessimistic locking with transaction+lock, or distributed locks like redlock / with_advisory_lock or upsert/rescue ActiveRecord record not unique; each trades latency or complexity.
AI-written summary · about
chapters (5)
- 0:00Start
- 19:52Important note
- 29:01Removing the critical section
- 30:26Detect and Recover
- 31:22Protect critical section








