52A Logs Rollbacks Why do we keep a log of transactions to
5-2-A Logs & Rollbacks
Why do we keep a log of transactions to aid in recovery of databases for disaster recovery? How does the log enable rollbacks of transactions? Put your answers in a one-page essay.
Solution
Database has a transaction log that records all transactions and the database modifications made by each transaction. The transaction log is a critical component of the database. If there is a system failure , you will need that log to bring your database back to a consistent state.
Log is a sequence of records , which maintains the records of actions performed by a transaction. It is important that the logs are written prior to the actual modifications and stored on a stable storage media , which is failsafe.
Log-based recovery works as follows :
. the log file is kept on a stable storage media.
.when a transaction enters the system and starts execution , it writes a log about it.
Each database , the transaction log can support following operations :
The transaction log must be truncated regularly to keep it from filling. Some factors can delay log truncation , so monitoring log size matters. Some operations can be minimally logged to reduce their impact on transaction log size.
The transaction log supports the following operations :
. individual transaction recovery.
. recovery of all incomplete transactions when database server is started.
. Rolling a restored database , file , file group , or page forward to the point of failure.
. supporting transactional replication.
. supporting high availability and disaster recovery solutions : Always on availability groups , database mirroring , and log shipping.
In database a rollback is an operation which returns the database to some previous state. Rollbacks are important for database integrity , because the database can be restored to a clean copy even after some error operations are performed .it is crucial for recovering from database server crashes; by rolling back any transaction which was active at the time of crash , the database is restored to a consistent state.
The rollback feature is usually implemented with a transaction log..
The transaction log provides the means by which either the complete set of tasks of a database transaction are performed or none of them are. It ensures that , via rollback , only valid data is written out to the database , and it allows transactions to be played back to recreate the system state right before a failure.
Databases are maintain the recovery model , which determines how log transactions are logged , whether the transaction log can be backed up , and the type of restore operations permitted.
