
There are two ways to guarantee that a crowd of transactions never trample each other, and they disagree about when to pay the price of vigilance.
The first way is the cage. Two-Phase Locking demands permission before any touch. A transaction must acquire a lock before it reads or writes, holding it through a growing phase of accumulation, and releasing nothing until the shrinking phase begins at commit. Every other transaction that wants the same resource simply waits, frozen, until the cage opens. Safety is bought upfront, in the currency of patience.
The second way is the alarm. Optimistic schemes let every transaction run free, reading and writing without asking permission, betting that no one will collide. Only at the end does the system check for betrayal: a validation phase that hunts for the exact topology of conflict, the anti-dependency cycles where one transaction's read was undone by another's write before it could see the truth.
The cage prevents disaster by refusing to let it start. The alarm prevents disaster by refusing to let it finish. One pays in throughput, holding resources hostage against a crime that might never happen. The other pays in occasional ruin, discarding a transaction whole after all its work is done. Neither trusts the crowd; they merely disagree about which moment deserves the suspicion.