Notestransactions🌱 seedling
Serializability
Also: Serializable · Serializable Isolation · Conflict Serializability · Strict Serializability · Precedence Graph
Concurrent transactions are serializable if the result equals running them one at a time in some order. It's the only isolation level with no anomalies to design around: a transaction that's correct alone stays correct, or fails to commit.
Why it exists
Weak levels leave a list of anomalies (Lost Update, Write Skew, Phantom Reads) that you can only avoid by reasoning about every pair of transactions. Nobody does that reliably.
How it works
- Dependency graph: draw an edge T1 → T2 when T2 reads what T1 wrote (wr), overwrites it (ww), or T1 read something T2 later overwrote (rw). No cycle means serializable; any topological order is an equivalent serial order.
- Three families provide it: Actual Serial Execution, Two-Phase Locking (pessimistic), and optimistic schemes such as Serializable Snapshot Isolation and Optimistic Concurrency Control.
- Strict serializability adds real-time order: if T1 commits before T2 starts, T1 comes first. Plain serializability allows a stale but consistent order.
Trade-offs
| Gains | Costs |
|---|---|
| no anomalies; local reasoning | blocking, aborts or a single thread, depending on implementation |
| invariants hold without explicit locks | clients must retry aborted transactions |
In practice
- Defaults: CockroachDB and FoundationDB default to serializable; Postgres, MySQL and Oracle don't. Oracle's "Serializable" is really Snapshot Isolation.
- Verification: Jepsen's Elle checker builds the dependency graph from test histories and reports cycles by type (G0, G1c, G-single, G2).
Pitfalls
- Serializable is not "fresh": without strictness, a read can be ordered before writes that already committed.
- It needs a retry loop; abort is the mechanism, not a malfunction.
Connections
- Part of
- Transactions
- Contains
- Actual Serial ExecutionOptimistic Concurrency ControlSerializable Snapshot IsolationTwo-Phase Locking
- Learn first
- Write Skew
- Contrasts with
- LinearizabilitySnapshot Isolation
- Related
- Isolation Level
- In real systems
- PostgreSQLCockroachDBVoltDB
- Mentioned
- Lost UpdatePhantom Read
Recall
These cards are also in your review deck, scheduled with spaced repetition.