All posts
Engineering·4 min read

How atomic regional locks work at checkout

A look under the hood at how Spokenfor guarantees exactly one owner per region, even when two buyers check out at the same moment.

The hard part of selling exclusivity isn't the marketing — it's making sure the promise is never broken. If two buyers in the same city can both complete checkout, the entire product falls apart.

Claim, then confirm

When a buyer enters checkout, Spokenfor takes a short-lived reservation on the region for that product. The reservation is written with a uniqueness constraint on (product, region), so a second concurrent attempt fails immediately rather than racing.

  • Reservation is created at checkout start and expires automatically if the order isn't completed.
  • Order completion promotes the reservation into a permanent claim.
  • Refunds and cancellations release the region back to the pool.

Why atomic matters

Anything less than an atomic write means a window where two orders can both look valid. With a database-level constraint, that window doesn't exist: one claim wins, the other buyer sees the region marked as taken before they pay.

That guarantee is what makes the public ledger trustworthy — and a trustworthy ledger is the whole reason exclusivity converts.