Skip to content

Async

Two writers, one record

Read, modify, write — across a network round trip, twice, at once.

12 minutes · read-modify-write · atomic update · optimistic concurrency

The shape of a lost update

Read a value, compute something from it, write the result back. On its own that is fine. Two of them overlapping is not: both read the same starting value, both compute from it, and the second write erases the first. Nothing errors. The count is simply one lower than it should be, forever.

Over a network the gap is enormous — two round trips wide — which is why this is the single most common bug in code that updates a record it just fetched.

Everything you do here stays in this browser.