E-commerce and payments
What is Race condition?
A race condition is a bug where the outcome depends on the timing of concurrent operations. In e-commerce it produces oversold stock, duplicate orders and double-charged customers — and it is invisible in testing because tests run one at a time.
Also called: concurrency bug
Where they show up in a store
- Two customers buying the last item simultaneously
- A webhook delivered twice while the first is still processing
- A customer double-clicking submit on a slow connection
- A scheduled job running while a user edits the same record
The fixes
- Database transactions around read-then-write sequences, not around the write alone
- Unique constraints, which turn a race into a clean error instead of duplicate data
- Idempotency keys on anything a client might retry
- Disabling the submit button is a courtesy, not a fix — the server must still be safe
Why they survive to production
Manual testing is sequential by nature. Nobody clicks twice in the same millisecond, and nobody replays a webhook mid-processing, so the bug ships and appears on the first busy day.
Where this is covered in depth
A definition can only go so far. E-commerce website development: what the whole build actually involves covers this properly — 7 minutes, free, no email required.
Who wrote this
Anas Bin Masud builds e-commerce sites and does technical SEO for businesses in the UK, Canada and Pakistan. These definitions come from client work rather than from a content brief — where an entry describes a mistake, it is usually one found on a real site. More about how I work.