Information Technology Reference
In-Depth Information
2. Commit. Append a commit record to the log, indicating that the trans-
action has committed.
Of course a transaction may roll back rather than commit. In this case, a
roll-back record may be placed in the log to indicate that the transaction
was abandoned. Writing a roll-back record is optional, however, because a
transaction will only be regarded as committed if a commit record appears
in the log.
3. Write-back. Once the commit record is persistent in the log, all of a
transactions updates may be written to their target locations, replacing
old values with new ones.
Once a transaction's write-back completes, its records in the log may be
garbage collected.
The moment in step 2 when the sector containing the commit record is
successfully stored is the atomic commit : before that moment the transaction
Definition: atomic commit
may safely be rolled back; after that moment, the transaction must take effect.
Recovery. If a system crashes in the middle of a transaction, it must execute a
recovery routine before processing new requests. For redo logging, the recovery
routine is simple: scan sequentially through the log, taking the following actions
for each type of record:
1. Update record for a transaction. Add this record to a list of updates
planned for the specified transaction.
2. Commit record for a transaction. Write-back all of the transaction's
logged updates to their target locations.
3. Roll-back record for a transaction. Discard the list of updates planned
for the specified transaction.
When the end of the log is reached, the recovery process discards any update
records for transactions that do not have commit records in the log.
Example. Consider, for example, a transaction that transfers $100 from Tom's
account to Mike's account. Initially, as Figure 14.2-(a) shows, data stored on
disk and in the volatile memory cache indicates that Tom's account has $200
and Mike's account has $100.
Then, the cached values are updated and the updates are appended to the
nonvolatile log (b). At this point, if the system were to crash, the updates in
cache would be lost, the updates for the uncommitted transaction in the log
would be discarded, and the system would return to its original state.
 
Search WWH ::




Custom Search