πŸ“š What is MVCC?

MVCC (Multi-Version Concurrency Control) is a concurrency control technique used by databases like PostgreSQL, Oracle, MySQL InnoDB, etc.

βœ… What MVCC does:

πŸ”’ Isolation levels that use MVCC:


🧠 What is SSI (Serializable Snapshot Isolation)?

Serializable Snapshot Isolation (SSI) is a way to achieve serializability β€” the strongest isolation level β€” without locking every read.

It's like Snapshot Isolation (MVCC-based) but with conflict detection.

If two transactions could violate serializability, one is aborted at commit.

Used in: PostgreSQL's SERIALIZABLE isolation level.


πŸ§ͺ Let’s Revisit Your Race Conditions with MVCC & SSI

Race Condition MVCC Handles? SSI Handles? Why
🧼 Dirty Read βœ… Yes βœ… Yes MVCC never shows uncommitted data
πŸ– Dirty Write βœ… Yes βœ… Yes Writes are versioned; write-write conflicts abort one txn
πŸ”€ Lost Update ❌ No βœ… Yes MVCC allows read-modify-write races unless locked; SSI detects conflict and aborts
🀹 Read Skew (Non-Repeatable Read) βœ… Yes βœ… Yes MVCC gives a consistent snapshot
🎲 Write Skew ❌ No βœ… Yes MVCC sees consistent state, but both txns may write conflicting data (e.g., doctor off-call); SSI aborts
πŸ‘» Phantom ❌ No βœ… Yes MVCC can’t lock range predicates; SSI tracks predicate reads and aborts conflicting inserts