All articles

October 19, 2026 · 1 min read

Race condition: two tickets for one seat

When two people act on the same data at the same time, the result depends on who goes first. The last concert seat example.

  • tech
  • basics

A "race condition" is literally a race: two actions compete for the same piece of data, and the result depends on who gets there first.

The example: the last concert seat

There is one seat left. Alice and Bob click at the same time. Both see "1 seat available", and both buy.

The site does two things: it checks that a seat is left, then it sells. But in between, the other person slipped in. Result: two tickets sold for a single seat.

That is a race condition: the result depends on who goes first. And because it depends on timing, it is a bug that is hard to reproduce.

The fix: a lock

You put a lock: checking and selling become one single step, which cannot be cut in two. Alice buys, Bob waits, and he sees "sold out".

Remember

Shared data, simultaneous access: you need a lock. In practice, depending on the tool, you use a transaction, a lock or an atomic update.