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.

Related terms

All 184 terms in the glossary →

Want this handled rather than explained?

Send the brief and you get a reply within one business day — either questions, or a scoping call. If your project is not something I should take on, I will say so then.

Response
Replies within 1 business day
Hours
Mon–Fri, 09:00–18:00 PKT — overlaps 05:00–14:00 UK, 00:00–09:00 US Eastern
Booking
Booking projects from October 2026
WhatsApp — opens a chat with +92 346 5348466 in a new tab