SQL transactions and isolation levels under concurrent writes

11 steps · about 4 h 54 min · Intermediate

  1. Relational Database ACID Transactions - Explained by Example (video, Hussein Nasser (via Class Central), 43 min)

    Starts with what a transaction is and what ACID means, then names dirty, non-repeatable and phantom reads.

  2. How Databases Lock Your Data (ACID) (article, DEV Community, 6 min)

    A short lost-update story (two transfers, wrong balance) shows why isolation matters. It also introduces deadlocks and multiple row versions.

  3. SQL Transactions and Isolation Levels: The Ultimate Guide (article, Database Star, 15 min)

    Gives the four standard levels and the SET TRANSACTION syntax in one place.

  4. No Dirty Reads: Everything you always wanted to know about SQL isolation levels (but were too afraid to ask) (article, Cockroach Labs, 15 min)

    Relates each level to the anomalies it allows and the retry cost of stronger levels.

  5. PostgreSQL: Documentation: 13.2. Transaction Isolation (doc, PostgreSQL Global Development Group, 40 min)

    The official reference for how Read Committed, Repeatable Read and Serializable behave in one real database, including retry on serialization failure.

  6. PostgreSQL: Documentation: 13.3. Explicit Locking (doc, PostgreSQL Global Development Group, 30 min)

    Shows how SELECT FOR UPDATE and row locks stop lost updates when isolation alone is not enough, and how deadlocks arise.

  7. MySQL 8.4 Reference Manual: 17.7.2.1 Transaction Isolation Levels (doc, Oracle MySQL, 25 min)

    Compares InnoDB's locking approach and its REPEATABLE READ default with PostgreSQL's.

  8. Implementing MVCC and major SQL transaction isolation levels (article, Phil Eaton, 25 min)

    Building a tiny MVCC database makes the visibility rules behind each level concrete.

  9. Hermitage: Testing transaction isolation levels (repo, Martin Kleppmann (GitHub), 40 min)

    Runnable test cases show that databases' isolation level names don't always match their real behaviour, so you can check it yourself.

  10. Snapshot Isolation (reference, Jepsen, 15 min)

    Explains write skew, the anomaly that snapshot isolation allows and serializability does not.

  11. Jepsen: PostgreSQL 12.3 (reference, Jepsen (Kyle Kingsbury), 40 min)

    A real-world test of PostgreSQL's isolation levels, to cap off the theory.