Chapter 30. Transactions
30.0 Introduction
Transactions describe a systemâs cability to support tentative or multistep changes. When you make changes within the context of a transaction, the system provides four main guarantees:
- Isolation
-
To observers not participating in the transaction, the commands inside the transaction havenât impacted the system.
- Atomicity
-
Once you decide to finalize (commit) a transaction, either all of the changes take effect or none of them do.
- Consistency
-
Errors caused during a transaction that would cause an inconsistent system state are dealt with to bring the system back to a consistent state.
- Durability
-
Once the system has informed you of the transactionâs successful completion, you can be certain that the changes are permanent.
As a real-world example of a transaction, consider a money transfer between two bank accounts. This might happen in two stages: subtract the money from the first account, and then add the money to the second account. In this situation, you have the exact same goals for robustness and correctness:
- Isolation
-
While the money transfer is taking place (but has not yet completed), the balance of both bank accounts appears unchanged.
- Atomicity
-
At some point in the process, itâs possible that weâve subtracted the money from the first account but havenât added it yet to the second account. When we process the money transfer, itâs critical that the system never show this intermediate state. Either all of ...
Get PowerShell Cookbook, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.