All or none, written in the registers of state.
A transaction is the smallest indivisible motion of meaning across a system. We treat the verb commit with the gravity of a notary: every observed change must be undoable until the moment it isn't. Between BEGIN and COMMIT lies a small kingdom of provisional truth.
BEGIN;
UPDATE accounts SET balance = balance - 100 WHERE id = 'A';
UPDATE accounts SET balance = balance + 100 WHERE id = 'B';
COMMIT;
Concurrent readers, lonely writers.
Snapshot, repeatable read, serializable — each level is a treaty between throughput and truth. The discipline is to pick a level and write the system that earns it. We dwell on phantom reads, write skew, and the geometry of conflict graphs.
- READ COMMITTEDwrites invisible until commit
- REPEATABLE READsnapshot at first read
- SERIALIZABLEconflict-graph acyclic
Invariants are the syllabus of the system.
A consistency model is a contract written in the negative — what shall never appear. The work of transactology is to translate these refusals into checks, constraints, and proofs. From referential integrity to causal order, the rules accumulate like marginalia in a well-loved textbook.
Once committed, the universe must remember.
Write-ahead logs, fsync barriers, replication quorums — the apparatus by which a fact survives the loss of its container. In this chapter we audit the path from RAM to platter, from log buffer to cold archive, treating each hop as a potential betrayal.