The Real Meaning of ACID: Atomicity and Durability (WAL) 00:00:01 A transfer has two halves and one promise Alice sends Bob a hundred dollars. After any recovery the money must be in one account or the other. Atomicity groups the two changes, and consistency includes the application's rule that the total is conserved. Transaction 42 starts. Alice has $1,000 and Bob has $500. Without a transaction $100 is gone. With one, the log holds no COMMIT, so recovery puts $1,000 back. Without a crash the work goes on: Bob goes to $600. The COMMIT record is forced to disk. Now the change is permanent and others may see it. Isolation controls what concurrent work may observe. Durability gives a successful commit a specified survival guarantee. Always ask what failure the configured storage and replication policy actually survives. 00:00:58 Put the promise on disk first The database need not rewrite every account page before answering Alice. It first records enough information in a write-ahead log to reconstruct the committed state after a crash. balance equals 900. The page in memory changes. Nothing is on disk. fsync forces the log to stable storage. This wait is most of the cost of a short transaction. The client hears "committed", although the data file still says 1000. A checkpoint notes how far the data files have caught up. Recovery can start from there. A checkpoint limits the work recovery must revisit. The correctness rule is the ordering between durable log and dependent data pages, rather than an assumption that every changed page is already on disk. 00:01:49 Recover a committed and an unfinished transfer Turn the power off while two transactions are in flight. Follow the record of each transaction separately. An updated page found on disk alone does not prove that its transaction committed. Transactions 42 and 43 are at work. Memory is lost. On disk Alice is still 1000, and Cara's page was already written as 20. Replay from the checkpoint. Alice 900, Cara 20, Bob 600. Alice 900, Bob 600, Cara 70. All of 42, nothing of 43. Different engines represent undo and visibility differently. Judge the demonstration by the final observable balances, where all the effects of the committed transfer survive and the abandoned one exposes none. 00:02:43 Twenty people share the same flush Suppose stable storage takes five milliseconds per flush. Group commit lets several waiting transactions share that physical operation while each still receives an individual logical outcome. One five-millisecond flush per individual commit would allow about two hundred commits per second. While one flush runs, 20 other transactions finish their work and wait. If each flush covers twenty ready commits, the illustrative flush-limited throughput becomes four thousand commits per second. Answering before the flush is faster still, and a crash may lose the newest transactions. Use it only for data you can lose. This arithmetic illustrates a ceiling under the stated assumptions. Queueing, replication and other load change measured throughput. Acknowledging before required durability is a separate policy that changes the failure promise. 00:03:39 The card network lives outside the transaction The shop has one local database and an external payment provider. Its local transaction cannot single-handedly roll back a remote charge. A crash in that gap can leave a paid customer with no order. The card is charged $299 and stock falls from 5 to 4. The server dies before the order is written. One local transaction stores the order as pending, reserves the stock and records that a charge must be made. A worker charges the card with the order number as idempotency key. After a crash it can try again without charging twice. Record the obligation locally, deliver it with a stable idempotency key and reconcile uncertain replies. ACID protects the database transaction. The conversation with a second system also needs a recovery protocol.