Skip to content

Race condition

A result depends on the timing of overlapping accesses and can therefore be wrong.

Software architecture

What is a race condition?

A race condition arises when a result improperly depends on the timing order of concurrent workflows. Several operations often access shared state without suitable coordination. They need not execute simultaneously on multiple processor cores. Interleaved accesses can also produce an unsuitable order.

In a fictional portal, two reservation requests check the same last available item. Both initially see availability and could report success without appropriate protection. Checking and reservation must therefore be protected together so that only one request can successfully reserve the last item; only the result determines the feedback. Merely opening a database transaction does not establish that this conflict is prevented. The team specifically checks overlapping workflows and the protection used.

Sources