148 ADDITIONAL TOPICS
tion as incomplete. Then, if the credit operation fails, the incomplete debit operation
can be rolled back; but if it succeeds, the debit operation is marked as complete or
committed. This approach provides for atomicity—either everything succeeds or
nothing does. In fact the characteristics of a transaction are described by the acronym
ACID, which stands for atomicity, consistency, isolation, durability. We already cov-
ered atomicity (all or nothing).
Consistency is the requirement that whatever is being updated should always be in
a consistent state. Atomicity is one of the characteristics that help with this.
Isolation implies that each transaction should neither affect nor be affected by any
other transaction. While the operation in the earlier transaction is in progress, no other
transaction can update those accounts until the current transaction is completed (all
operations in the transaction are committed, or all operations are rolled back).
The final characteristic is durability. This means that once a transaction has been
committed, that state won’t be lost (for example, by a power outage or a disk failure).
Obviously this is easier said than done, but techniques exist to guarantee durability to
a sufficient degree.
Compensations versus rollback
Transactions may have come from the financial world, but the concepts have been
applied in a lot of other fields. Unfortunately, whereas updating a database in a con-
sistent way is relatively easy, in other fields, many operations can’t be rolled back. For
example, you can’t unlaunch a missile. To deal with these situations, an alternate
approach to provide a sufficient degree of consistency is to use compensating actions.
Instead of rolling back the original operation, you do something else to try to get
the system back to an equivalent consistent state. In the missile example, if the missile
is heading toward the wrong target, this might involve destroying that missile and
then moving a new missile to the launching pad. The state of the system isn’t identi-
cal to the original state, but it’s still consistent. Now let’s see how you can apply
transactions in systems management.
Transactions in the management world
Transactions are obviously useful in system administrations: the ability to update a
database in such a way that it’s always consistent and that all changes are isolated and
durable is the Holy Grail for many researchers working in the management space.
Unfortunately, it’s hard to achieve due to the heterogeneous nature of management
operations. Many things can’t be unlaunched—deleted files, reformatted disks, over-
writing a file, and so on. Before you can perform transacted operations, you need to
be able to roll back or compensate for each of these elements.
D.5.2 Transactions in PowerShell
In this section, we’ll look at how transactions apply in PowerShell. As a caveat, unlike
remoting or eventing, transactions aren’t a fully elaborated feature in
V2. This means