← Back

Concurrency Anomalies

4 min read

When multiple transactions interleave their read and write operations on shared database objects without proper coordination, several concurrency anomalies (race conditions) can occur. This post walks through each one — and how databases detect and prevent them.


When Transactions Interleave, What Can Go Wrong?

When two transactions read and write the same objects at the same time, their operations can interleave in ways that produce outcomes no serial execution would ever reach. There are three fundamental conflicts.

Read-Write Conflict (Unrepeatable Read)

Write-Read Conflict (Dirty Read)

Write-Write Conflict (Lost Update / Blind Write)


So How Do Databases Detect and Prevent These?

Serializability

Serializability is the fundamental standard for correctness: an interleaved execution schedule is serializable if its final outcome on the database state is identical to running those transactions sequentially, one after another, in some serial order.

Conflict Serializability & Dependency Graphs

But testing every possible database state is impractical — so how does the database verify serializability efficiently?

It uses conflict serializability through a dependency graph (precedence graph):

View Serializability

There's also a broader, more relaxed definition — view serializability — which allows certain schedules that conflict serializability rejects, such as particular sequences of blind writes, or schedules where higher-level application logic still ensures a correct end result.

So why don't real databases use it? Because view serializability requires the engine to inspect and interpret application-level program logic — or ask a human developer what the queries actually mean. Database systems don't know upcoming queries in advance and can't infer intent, so every real-world engine uses conflict serializability instead.