Replicas eventually agree on the same value if writes stop
No timing guarantee
Anomalies possible during normal operation
Linearizability vs. Serializability
Property
Type
Guarantee
Serializability
Isolation (transactions)
Txs behave as if executed serially (no time constraint)
Linearizability
Recency (individual reads/writes)
Operations respect real-time ordering
2PL and actual serial execution → linearizable
SSI → not linearizable by design (optimistic, snapshot-based)
Strict serializability = both linearizable + serializable
ACID Isolation Levels
Isolation Levels (weakest → strongest)
Level
Prevents
Allows
Read Uncommitted
Nothing
Dirty reads, phantom reads
Read Committed
Dirty reads/writes
Read skew, lost updates, phantom reads
Repeatable Read / Snapshot
+ Read skew, lost updates
Phantom reads (some DBs)
Serializable
All anomalies
—
Concurrency Anomalies
Anomaly
Description
Fix
Dirty read
Read another tx's uncommitted data
Read committed
Dirty write
Overwrite another tx's uncommitted data
Row-level locks
Read skew
See different snapshots mid-tx
Snapshot isolation (MVCC)
Lost update
Two concurrent read-modify-write, one lost
Atomic ops, explicit lock, auto-detect, CAS
Write skew
Two txs read same data, write different objects → invalid state
Serializable, FOR UPDATE
Phantom read
New rows appear mid-tx matching a query
Serializable, materialized conflicts
Snapshot Isolation (MVCC)
Each tx reads from a frozen snapshot at start time
Readers never block writers; writers never block readers
DB keeps multiple object versions (MVCC)
Prevents read skew — good for backups, analytics, integrity checks
-- Read committed: per-statement snapshot
-- Snapshot isolation: per-transaction snapshot
BEGIN;
SELECT balance FROM accounts WHERE id = 1; -- sees snapshot at BEGIN
-- another tx writes balance=200 here
SELECT balance FROM accounts WHERE id = 1; -- still sees original value
COMMIT;
Lost Update Solutions
-- Atomic write (best when expressible)
UPDATE counters SET value = value + 1 WHERE key = 'x';
-- Explicit lock
SELECT * FROM docs WHERE id = 1 FOR UPDATE;
-- Compare and set
UPDATE docs SET content = 'new' WHERE content = 'old';
Solution
Notes
Atomic write
Best — database handles internally
Explicit lock (FOR UPDATE)
Works but easy to forget
Auto-detection
DB detects + aborts; works with snapshot isolation
CAS
May fail on old snapshot reads
Conflict resolution (replicated)
Allow conflicts, merge or LWW
CAP and Consistency Choice
Systems not requiring linearizability → more tolerant of network partitions
Causal consistency = strongest achievable without sacrificing availability under partitions
80/20 rule: most apps only need read-your-writes + monotonic reads — much cheaper than full linearizability