Race Conditions: When Two Correct Actions Produce a Wrong Result

Race Conditions: When Two Correct Actions Produce a Wrong Result

A race condition occurs not because one action is inherently wrong, but because several actions share the same state and the result unexpectedly depends on which happens first. A system meant to care only about what was done becomes vulnerable to exactly when it was done.

Suppose one ticket remains. Two customers check almost simultaneously, both see that it is available, and each proceeds to pay. If checking availability and reducing the inventory are separate operations, two individually reasonable flows can sell the same seat. The problem is not that the customers are competing; it is that the shared state lacks sufficient constraint.

This differs from ordinary ordering. If arrival time is explicitly part of the rule, first come, first served is not an error. It also differs from deadlock, where participants wait on one another and none can continue. Preventing a race means protecting checks and updates that must hold together, or making conflicts detectable and retryable. The broader lesson is that whenever people, programs or institutions alter the same thing concurrently, timing can become part of the system itself.


Discover more from Geoffrey Chen

Subscribe to get the latest posts sent to your email.