Database Systems
Database Systems
Database Systems
Atomicity refers to the ability of rejecting the entire unit of a transaction of database, if one part
of it fails to commit.
Consistency ensures consistence state of a database before the start of the transaction and
after the transaction is over, whether successful or not (Lightwolf, 2009).
Isolation refers to the ability of being able to view an operation of a transaction isolated and it
determines the integrity of a transaction within several users of a system.
Durability refers to the guarantee that once a transaction is successfully committed, it remains
persistent even after a database crash. These are considered as transactions that have been
written to the log and incase of a failure, can be retrieved to generate the database to its former
state before the failure. (Doctrine, 2012).
If a database crashes amid transaction being executed there should be some techniques or
mechanism to rectify the database to its former state from the failure or crash, from which point the
database can be brought back to function. There can be many reasons due to which a database can
fail or crash such as transaction failure, system crash or media failure.
The recovery manager which is a hardest component of DBMS is called during system
failures. It ensures two properties of any transactions namely atomicity and durability.
Atomicity is ensured by undoing the uncommitted actions of transactions and durability by
ensuring that all the actions of committed transactions are persistent and survive system
crashes (Ramakrishnan & Gerke 2003).
2. ARIES recovery algorithm
ARIES is a recovery algorithm based on Write-Ahead Log (WAL) protocol, which records
every update operation into the log. Ramakrishnan & Gerke (2003) suggests that ARIES is
conceptually simple and compatible with a wide range of concurrency control mechanisms and also
designed to work with a steal, no-force approach. When the recovery manager is invoked following a
database crash, restart should proceed in three phases:
Page 1 of 5
Analysis phase: Determines the earliest log record from which point to start the next phase
i.e. Redo. It identifies the dirty pages in the buffer pool and active transactions at the time of
the crash.
Redo phase: Repeats all actions where actions should be undone, starting from the point in
the log determined in the analysis phase, and restores the database to its former state,
what it was at the time of crash.
Undo phase: Undoes the actions of transactions which were active and did not commit at
the time of the system crash as determined by the analysis phase, so that the database
results only the committed transactions.
One of the main three principles behind the Aries algorithm is Write-Ahead Protocol.
3. Write-Ahead Logging
WAL (Write-Ahead logging) is method that ensures the data integrity of a database. Every
update log record that requests a change to a page must be recorded in a stable storage before the
actual alteration is written in the particular page. WAL protocol ensures two of the ACID properties
in a database system, namely atomicity and durability. WAL is used to flush log records to the
persistent log file before data pages are written (Website Hosting Blog, 2012).
A significance of WAL is that it ensures the availability of the records of every change to the
Database, while attempting to recover from a database failure or crash. Without WAL there
wouldnt be a method to ensure that the changes of a committed transaction survive crashes.
Committed transaction refers to a transaction whose log records including log record have all been
written to the stable storage (Ramakrishnan & Gerke, 2003).
There is no necessity to flush data pages after every transaction commit, because of the
assurance from the WAL protocol that at an event of a crash the database can be recovered using
the log. Any transactions that have not been applied to the data pages can be redone from the log
record. This process is called as forward recovery. Using WAL reduces the number of disk writes
since only need to guarantee a transaction to be committed is to flush the log file to the disk rather
than every data file changed by the transaction (PostgreSQL, 2014).
Further all the writes to the log file are sequential writes because the log is maintained in a
sequential file. When a transaction is committed the log tail (the most resent part of the log record)
is forced to stable storage where in contrast if a force approach is used, instead of a portion of the
log all the pages modified by transaction must be forced to disk following each transaction commits.
Therefore, compared to the cost of writing all changed pages to the disk, forcing only the log tail is
much smaller (Ramakrishnan & Gerke, 2003).
WAL also facilitates to support on-line backup and point-in-time recovery. By archiving the
WAL data it is possible to support reverting to any time instant covered by the available WAL data by
simply installing a prior physical backup of the database and replaying the WAL log to desired time
Page 2 of 5
Update
Commit
Abort
End
Undoing and update
A database log record contains:
There are also various types of log records which have the above attributes in common and may
have additional attributes depending on the type of the log.
5. Backward recovery
Also called as roll-back or Undo, a Forward Recovery procedure contributes to rectify a
database to the former state before a crash which is consistent enough, to proceed with the
transactions again. It uses the log file of before images to the crashed database to undo all the
uncommitted transactions that failed to commit due to system failure or crash. Any transaction
which failed or were active at the time of the crash can be rolled back to give a consistent state to
Page 3 of 5
6. Forward recovery
The Forward recovery which is also known to be roll-forward or redo is a recovery procedure
that re-does all the transactions that did not successfully commit at the time of the crash. The log file
of after image is used to achieve this process. Starting from the earlier copy of the database when
after images are applied, the database is moved to a later state, committing again all the
uncommitted transactions at the time of the crash. Only the most resent after image is applied.
Fig 6.1
Page 4 of 5
Ramakrishnan, R. & Gerke, J (2003) Database Management Systems: Crash recovery. Third
Edition. McGraw-Hill Companies, Inc., New York NY 10020.
Page 5 of 5