Database transactions and commit boundaries 00:00:01 Twenty-five credits leave the till A bookshop moves twenty-five credits between two customer accounts. One starts at a hundred, the other at forty. The transfer should change who owns the credits while preserving a total of one hundred forty. The program subtracts twenty-five. Its own unfinished work now contains seventy-five in the first account and forty in the second. If those were independent committed writes, a crash here would make twenty-five credits appear to vanish. Adding twenty-five to the second account produces seventy-five and sixty-five. The arithmetic is simple. The harder question is which intermediate results a failure permits the system to expose as the finished transfer. 00:00:42 Draw a local commit boundary Put both balance changes in a single database transaction and include the required funds check. Every row needed for this guarantee must be under the transaction mechanism that can commit or roll it back. If the process dies before commit, recovery must leave no partial committed transfer. The database may already have written internal bytes. Atomicity concerns the resulting logical transaction, not whether a disk head moved. After a successful commit under the promised durability settings, both changes are present together. Whether another reader sees them immediately also depends on its isolation snapshot and any replica it reads. 00:01:25 The reply disappears The shop loses its connection after sending commit but before receiving the result. From the client's side, that looks like a failure. From the database's side, the money may already have moved. A fresh transfer would debit another twenty-five. Associate a stable operation key with this transfer and record its outcome with the balance changes. A caller can then retry or query that same intent. What if the retry carries a different amount? Matching a key is insufficient if the caller can change the meaning behind it. Reject the conflicting reuse and keep the original recorded outcome intact. 00:02:05 The email lives outside Suppose the shop sends a congratulatory email before the database commits. A rollback cannot pull the already delivered message out of the recipient's inbox. The provider is outside this local transaction boundary. Instead, commit the two changes and an outgoing receipt task together. When the transfer commits, a worker can discover the task. If the transfer rolls back, the task does not become a committed obligation. The worker can still lose a provider acknowledgement and send again. A repeat-safe provider contract or a business tolerance for duplicate notifications must address that separate delivery problem. 00:02:47 Which promise can you test? Test the balance invariant, test a crash between updates, and test a lost confirmation. They exercise distinct properties. A correct total in one happy-path test cannot demonstrate all three. If the accounts later move to independently committed stores, the local transaction no longer spans the transfer. Choose a supported distributed transaction or model pending value and recovery explicitly. The bookshop can now tell a customer whether those particular twenty-five credits moved, where they went, and whether the email is still pending. Those answers belong to different durable facts.