4.4.17 · D1Databases

Foundations — Transaction isolation levels — READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE

1,733 words8 min readBack to topic

Before you touch the parent note, you must be able to read its alphabet. Below is every symbol, term, and picture the parent leans on — built in an order where each one only uses things already defined.


1. What is a "row"? What is a "table"?

Picture the grid literally as squared paper: rows go across, columns go down, and the whole topic is about who is allowed to look at which cell, and when.

Figure — Transaction isolation levels — READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE

Why the topic needs it: every anomaly in the parent ("dirty read", "phantom") is a story about a specific cell or a specific set of rows being read at the wrong moment. Without the grid picture, "row" and "predicate" are just words.


2. What is a "transaction"?

Why the topic needs it: isolation is only interesting because transactions overlap in time. If they never overlapped, there would be nothing to isolate.

The all-or-nothing promise is the A in ACID properties (Atomicity). The I in ACID is literally Isolation — the exact letter this whole chapter zooms into.


3. COMMIT vs ROLLBACK vs "uncommitted"

Why the topic needs it: the three anomalies differ precisely by which of these three states was read. Dirty read = reading uncommitted. Non-repeatable read = reading committed data that changed. Lock this vocabulary now.


4. Concurrency and "interleaving"

Figure — Transaction isolation levels — READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE

Why the topic needs it: the parent's phrase "no serial order could produce this" is meaningless until you can picture the shuffle vs the two clean stacks.


5. "Serial" and "Serializable"

Why the topic needs it: "serializable" is the top rung of the parent's staircase and the gold standard the other levels are measured against.


6. A "predicate" and the WHERE clause

Figure — Transaction isolation levels — READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, SERIALIZABLE

Why the topic needs it: the parent's hardest distinction — non-repeatable vs phantom — is exactly content-of-the-circle vs membership-of-the-circle. This figure is the whole difference.


7. Locks and snapshots (the two "how" tools)

Why the topic needs it: the parent's implementation section ("hold read locks until commit", "one snapshot at transaction start") is unreadable without these two pictures. The higher the isolation level, the longer you hold locks or the more frozen your photo.


8. The symbols/notation the parent uses

Why the topic needs it: every worked example in the parent is written in exactly this shorthand.


Prerequisite map

Table and rows

Transaction

Commit vs Rollback

Committed vs Uncommitted data

Concurrent interleaving

Serial vs Serializable

Predicate and result set

Read anomalies

Locks and Snapshots

Isolation levels dial

Read it bottom-up: rows and transactions feed the ideas of committed data and interleaving; those plus the predicate define what an anomaly even is; locks and snapshots are the machinery; the isolation-level dial sits on top of all of it.


Equipment checklist

Test yourself — cover the right side and answer out loud.

A table, a row, a column — what is each?
A table is a grid; a row is one thing (one account); a column is one property (bal). A cell is one property of one thing.
What is a transaction?
A bundle of steps that is all-or-nothing, ending in COMMIT (keep) or ROLLBACK (undo).
Difference between committed, uncommitted, and rolled-back data?
Committed = permanent & official; uncommitted = written but no gate pressed yet, may vanish; rolled back = thrown away.
What does "interleaving" mean?
Running a step of T1, then a step of T2, then back — shuffling two decks instead of stacking them.
Does "serializable" mean transactions run one at a time?
No — it means the concurrent result equals some serial order; they still run concurrently.
What is a predicate?
A yes/no rule after WHERE (e.g. age > 30) deciding which rows are in the result set.
Content-change vs membership-change of the result circle — which anomaly is which?
Content change (existing row's value) = non-repeatable read; membership change (row appears/disappears) = phantom read.
What is a lock? A snapshot?
A lock is a "do-not-touch" tag forcing others to wait; a snapshot is a frozen photo of the DB at one instant.
Which ACID letter is this whole chapter about?
I — Isolation.

See also: ACID properties, Deadlocks, Write skew anomaly, and the parent Hinglish version.