Algorithms for Recovery and Isolation Exploiting Semantics: Difference between revisions
Content deleted Content added
more content. no longer a stub. |
Link suggestions feature: 2 links added. |
||
(76 intermediate revisions by 68 users not shown) | |||
Line 1:
{{Short description|Recovery algorithm}}
In [[computer science]], '''Algorithms for Recovery and Isolation Exploiting Semantics''', or '''ARIES''', is a recovery [[algorithm]] designed to work with a [[no-force]], steal database approach; it is used by [[IBM Db2]], [[Microsoft SQL Server]] and many other [[database system]]s.<ref>{{cite journal|last1=Mohan |first1=C.|last2=Haderle |first2=Donald|last3=Lindsay|first3=Bruce|last4=Pirahesh|first4=Hamid|last5=Schwarz|first5=Peter|title=ARIES: A Transaction Recovery Method Supporting Fine-Granularity Locking and Partial Rollbacks Using Write-Ahead Logging|journal=ACM Transactions on Database Systems|date=March 1992|volume=17|issue=1|pages=94–162|doi=10.1145/128765.128770|doi-access=free}}</ref> [[IBM Fellow]] [[C. Mohan|Chandrasekaran Mohan]] is the primary inventor of the ARIES family of algorithms.<ref>{{cite web|title=Repeating History Beyond ARIES|url=http://www.vldb.org/conf/1999/P1.pdf|publisher=C. Mohan, Proceedings of the 25th International Conference on Very Large Data Bases, Edinburgh, UK, September 1999.}}</ref>
Three main principles lie behind ARIES:
* [[Write
*
*
▲* [[Repeating history during Redo]]: On restart after a crash, ARIES retraces the actions of a database before the crash and brings the system back to the exact state that it was in before the crash. Then it undoes the transactions still active at crash time.
The ARIES algorithm relies on logging of all database operations with ascending Sequence Numbers. Usually the resulting logfile is stored on so-called "stable storage", that is a storage medium that is assumed to survive crashes and hardware failures.
▲* [[Logging changes during Undo]]: Changes made to the database while undoing transactions are logged to ensure such an action isn't repeated in the event of repeated restarts.
▲== Logging ==
The dirty page table keeps record of all the pages that have been modified, and not yet written
We create log records of the form (Sequence Number, Transaction ID, Page ID, Redo, Undo, Previous Sequence Number). The Redo and Undo fields keep information about the changes this log record saves and how to undo them. The Previous Sequence Number is a reference to the previous log record that was created for this transaction.
▲Usually the resulting logfile is stored on so called "stable storage", that is a storage medium that is assumed to survive crashes and hardware failures. To gather the necessary information for the logging two datastructures have to be maintained: the dirty page table (DPT) and the transaction table (TT).
Every
▲The dirty page table keeps record of all the pages that have been modified and not yet written back to disc and the first Sequence Number that caused that page to become dirty. The transaction table contains all transactions that are currently running and the Sequence Number of the last log entry they caused.
During a recovery, or while undoing the actions of an aborted transaction, a special kind of log record is written, the Compensation Log Record (CLR), to record that the action has already been undone. CLRs are of the form (Sequence Number, Transaction ID, Page ID, Redo, Previous Sequence Number, Next Undo Sequence Number). The
▲We create log records of the form (Sequence Number, Transaction ID, Page ID, Redo, Undo, Previous Sequence Number). The Redo and Undo fields keep information about the changes this log record saves and how to undo them. The Previous Sequence Number is a reference to the previous log record that was created for this transaction. Using the Previous Sequence Numbers it is for example possible to traverse to log file in reverse order and undo all the actions of a specific transaction in case it aborts.
▲Every time a transaction begins or commits we write a Begin Transaction respectively an End Of Log entry for that transaction.
▲During a recovery or while undoing the actions of an aborted transaction a special kind of log record is written, the Compensation Log Record (CLR), to record that the action has already been undone. CLRs are of the form (Sequence Number, Transaction ID, Page ID, Redo, Previous Sequence Number, Next Undo Sequence Number). The Undo field is ommited because that information is already stored it the original log record for that action.
== Recovery ==
The recovery works in three phases. The first phase, Analysis, computes all the necessary information from the logfile. The Redo phase restores the database to the exact state at the crash, including all the changes of
=== Analysis ===
During the Analysis phase we restore the DPT and the TT as they were at the time of the crash.
We run through the logfile (from the beginning or the last checkpoint) and add all transactions for which we encounter Begin Transaction entries to the TT. Whenever an End Log entry is found, the corresponding transaction is removed. The last Sequence Number for each transaction is
During the same run we also fill the dirty page table by adding a new entry whenever we encounter a page that is modified and not yet in the DPT. This however only computes a superset of all dirty pages at the time of the crash, since we don't check the actual database file whether the page was written back to the storage.
Line 37 ⟶ 36:
=== Redo ===
From the DPT, we can compute the minimal Sequence Number of a dirty page. From there, we have to start redoing the actions until the crash, in case they weren't persisted already.
Running through the log file, we check for each entry, whether the modified page
=== Undo ===
After the Redo phase, the database reflects the exact state at the crash. However the
For that we run backwards through the log for each transaction in the TT (those runs can of course be combined into one) using the Previous Sequence Number fields in the records. For each record we undo the changes (using the information in the Undo field) and write a compensation log record to the log file. If we encounter a Begin Transaction record we write an End Log record for that transaction.
The compensation log records make it possible to recover during a crash that occurs during the recovery phase. That isn't as uncommon as one might think, as it is possible for the recovery phase to take quite long. CLRs are read during the Analysis phase and redone during the Redo phase.
== Checkpoints ==
To avoid
The naive way for [[Application checkpointing|checkpointing]] involves locking the whole database to avoid changes to the DPT and the TT during the creation of the checkpoint. Fuzzy logging circumvents that by writing two log records. One Fuzzy Log Starts Here record and, after preparing the checkpoint data, the actual checkpoint. Between the two records other
==
{{Reflist}}
==External links==
[[Category:Database algorithms]]▼
* {{citation |url=http://www.almaden.ibm.com/u/mohan/ARIES_Impact.html |title=Impact of ARIES Family of Locking and Recovery Algorithms - C. Mohan |archiveurl=https://web.archive.org/web/20120819161114/http://www.almaden.ibm.com/u/mohan/ARIES_Impact.html
|archivedate=2012-08-19
|accessdate=2013-09-18 }}
▲[[Category:Database algorithms]]
|