Availability Guide for Application Design
Data Protection and Recovery
Availability Guide for Application Design—525637-004
4-3
What Is a Transaction?
Each transaction is not affected by other transactions that are executing
concurrently. Transactions can take place in any order and the correctness of the
database transformation is not affected.
•
It is durable.
Once a transaction successfully finishes (it commits), its changes are permanent
and will survive even if a failure occurs.
Each of these topics is discussed in the following paragraphs.
Transactions Are Atomic
This property implies that either all changes take effect or none take effect. A typical
transaction might involve the transfer of funds from one account to another. For
example, transferring $1000 from a checking account to a savings account involves the
following steps:
1. Read the balance of the checking account.
2. Check that there are enough funds to complete the transfer; that is, the balance
must be greater than or equal to $1000.
3. Subtract $1000 from the checking account balance.
4. Write the new balance back to the checking account.
5. Read the savings account balance.
6. Add $1000 to the savings balance.
7. Write the new savings balance back to the savings account.
Suppose a failure takes place at some time during this sequence. There is no way of
knowing at exactly what point the failure took place, whether the checking account was
debited, or whether the savings account was credited.
To solve this problem, the transaction must become an atomic entity. That is, it must
either happen in its entirety, as if it were one operation, or not at all.
To achieve atomicity, TMF implements a commit protocol to ensure completion of all
aspects of the transaction. It keeps a before-image log of affected data blocks in a
sequence of special files known as the audit trail, in case a partial transaction must be
backed out.
Transactions Are Consistent
This property implies that the transaction program functions according to specification.
In the banking example given above, it implies that when the transaction is committed,
the checking account has $1000 less than when the transaction started and the
savings account has $1000 more.