Skip to content
>devspeak
← glossary
level 8Advanced AI-Assisted Development

Race condition

also: race conditions

A bug that happens when two things run at nearly the same moment and the result depends on which finishes first. It works most of the time, then fails unpredictably.

a bit more technical

A defect where correctness depends on the timing or order of overlapping operations. A classic form is check-then-act: two requests both check a condition, both see it as true, and both act before either records its change.

picture it

Two roommates each check the fridge, see there's no milk, and each go buy a carton. Neither was wrong to check. Both just checked before either got back.

why it matters

Race conditions hide during testing because you usually do one thing at a time. With real traffic they show up as double bookings, double charges, or lost updates. Naming it points your agent at timing, not just logic.

what your agent might say
agent
There's a race condition in seat reservation. Two requests can read the same remaining count before either saves. I'll do the check and the update in one transaction and lock the row while it runs.
how you might use it
you → your agent
Check whether the double-booking could be a race condition. Try to reproduce it with two simultaneous requests before changing anything, then explain your fix.
common mistake

Assuming a bug that happens only sometimes is a random glitch. Intermittent bugs are often race conditions: the code is wrong, but only when the timing lines up badly.

builds on