Undo and Redo Operations
Because all database modifications must be preceded by the creation of a log record, the system has available both the old value prior to the modification of the data item and new value that is to be written for data item. This allows system to perform redo and undo operations as appropriate:
- Undo: using a log record sets the data item specified in log record to old value.
- Redo: using a log record sets the data item specified in log record to new value.
The database can be modified using two approaches –
- Deferred Modification Technique: If the transaction does not modify the database until it has partially committed, it is said to use deferred modification technique.
- Immediate Modification Technique: If database modification occur while the transaction is still active, it is said to use immediate modification technique.
Log based Recovery in DBMS
The atomicity property of DBMS states that either all the operations of transactions must be performed or none. The modifications done by an aborted transaction should not be visible to the database and the modifications done by the committed transaction should be visible. To achieve our goal of atomicity, the user must first output stable storage information describing the modifications, without modifying the database itself. This information can help us ensure that all modifications performed by committed transactions are reflected in the database. This information can also help us ensure that no modifications made by an aborted transaction persist in the database.