Serializable Isolation
The best form of Isolation guarantee that a database can offer is Serializability, where each transaction can pretend that it is the only transaction running on the entire database. The database ensures that the result is the same as if the transactions had run serially when they have committed.
If transactions were executed one at a time, we would completely sidestep the problem of detecting and avoiding concurrency conflicts. However, this mode has become feasible only recently, with improvements in RAM size (to load the entire database into memory) and the understanding that OLTP transactions are typically small.
Most databases implement serializability in one of three ways:
- Execute transactions in a serial order
- Use Two-phase locking
- With Optimistic Concurrency Control techniques like Serializable Snapshot Isolation
In practice, however, serializable isolation is rarely used because of performance issues. Implementations of serializability either do not perform well (Two-phase locking) or don't scale well. Still, a database could use serializable isolation for OLTP transactions but switch to weaker isolation modes for long-running queries.
Related:
- Most databases do not support true Isolation
- Write Skew
- Phantom
- Serializable Isolation is the only way to prevent all write-related race conditions
- Optimistic Concurrency Control
- Two-phase locking
- Deadlock
- Two-phase Locking does not scale well
- Stored Procedures improve throughput by removing interactivity
- True serializability imposes system constraints
- Partitioning can improve throughput in serialized systems