# 4.4 Transactions (The Pinky Swear) ![Transactions: The Pinky Swear](/assets/arch_transactions_pinky.png) In the chaos of the warehouse, mistakes are inevitable. You might start moving coins from one pocket to another, only to get distracted halfway through by a passing peanut. If the elephant forgets where those coins went, they vanish into the digital void. To prevent this, the elephant uses **Transactions**—a formal **Pinky Swear** that a set of actions is one single, indivisible "Unit of Work." ## The Private Room (Isolation) When you start a transaction, the elephant leads you into a **Private Room**. While you are inside, you can scribble on your stone tablets, move your coins, and rearrange your suitcases as much as you like. Thanks to **MVCC**, you are working on your own private versions of the data. To the ten other elephants currently looking at the warehouse, nothing has changed. They see the world as it was before you entered the room. This is **Isolation**: it ensures your half-finished, messy work doesn't confuse anybody else. ## All or Nothing (Atomicity) Eventually, you reach the end of your task. You have two choices: 1. **COMMIT (The Grand Reveal)**: You yell "I'm done!" and the elephant officially records your success in the Pocket Diary (WAL). Instantly, your private versions become the "Truth" for everyone else. 2. **ROLLBACK (The Big Etch-A-Sketch)**: You realize you made a typo or changed your mind. You grab the elephant's trunk and scream "Never mind!" The elephant immediately throws your private tablets into the trash and pretends you never even entered the room. This is **Atomicity**. To the rest of the world, your work either happened completely or it didn't happen at all. There is no such thing as "halfway done" in the eyes of the elephant. ## The Waiting Game Pinky swears aren't free. While you are in your Private Room, you might be holding onto a cabinet that someone else needs. If you stay in there too long (Long-Running Transactions), other elephants start piling up in the hallway, sighing heavily. Being a good elephant means making your promises, finishing your work, and getting out of the room as fast as possible so everyone else can get back to their naps. --- [[Chapter 4/4.3 - Publications & Subscriptions|← 4.3 - Publications & Subscriptions]] | [[Chapter 4/4.0 - Safety Without Sweating|↑ 4.0 - Safety Without Sweating]] | [[Chapter 5/5.0 - The Hunger of Resources|5.0 - The Hunger of Resources →]]