Datatransaction isolationread committedrepeatable readserializable

Isolation level

Definition

An isolation level defines how much concurrent transactions can affect each other, by listing which anomalies (dirty reads, non-repeatable reads, lost updates, write skew) it rules out.

In practice

Stronger levels prevent more anomalies but cost more aborts or waiting. Postgres defaults to READ COMMITTED, a fresh snapshot per statement; REPEATABLE READ gives one snapshot per transaction; SERIALIZABLE makes the outcome equal to some serial order by aborting conflicting transactions. MySQL InnoDB defaults to REPEATABLE READ, with different semantics.

The same name means different things in different databases, so read the documentation rather than the SQL standard. Higher levels require retry logic for serialization failures (40001). Often a targeted fix at the default level, such as an atomic UPDATE or SELECT ... FOR UPDATE, is cheaper than raising the level for everything.

Example

Two bookings for the last seat both succeed under READ COMMITTED; under SERIALIZABLE one of them fails with 40001 and the application retries it, then sees the seat is gone.