1. Recovery
Recovery means recovering the database itself; that is restoring the database to a state that is known to be a correct or consistent after some failure has rendered the current state inconsistent or at least suspect. It is based on redundancy principle. There is only one way to make sure that database recoverable, is to make sure that any piece of information it contains can be reconstructed from some other information stored somewhere else in the system. Recovery or any transaction processing is independent of underlying system i.e. if it is relation or something else.
2. Transactions
Transaction is a logical unit of work. For e.g. consider SUPPLIER Relvar S and following sequence of transactions to be performed on it. BEGIN TRANSACTION; INSERT INTO S RELATION {TUPLE {S# S#(S3), SNAME (SMITH), STATUS (30), CITY (MUMBAI)}}; IF ANY ERROR OCCURRED THEN GOTO UNDO; END IF; UPDATE S SET STATUS: =10 WHERE S#=S#(S3); IF ANY ERROR OCCURRED THEN GOTO UNDO; END IF; COMMIT; GOTO FINISH; UNDO: ROLLBACK; FINISH: RETURN; END TRANSACTION; The constraint is, supplier from MUMBAI must have status > 20. So, in between insert and update operation it might be possible that database is not consistent and may violate the constraint.
CITC
Vishwas Raval
3. Transaction Manager
The system component that provides atomicity is known as TM or transaction processing monitor (TP Monitor). COMMIT and ROLLBACK operations are the key the way it works.
COMMIT:
It signals successful end of transaction. The database is again in a consistent state after complete transaction and all of the updates can now be COMMITTED i.e. made permanent.
ROLLBACK:
It indicate un-successful end of transaction. The database might be in an inconsistent state because of something might has gone wrong during transaction and all of the updated made by the logical unit of work must be ROLLED BACK or undone. Whenever, we execute any transaction, the system maintains a log or journal on tape or disk on which details of all updates before and after images of updated objects are recorded. So, it becomes necessary to undo some particular update. The system can use corresponding log entry to restore the updated object to its previous value.
4. Transaction Recovery
Any transaction begins with successful BEGIN TRANSACTION statement and ends with successful execution of either COMMIT or ROLLBACK statement. COMMIT point is also called synchpoint, it corresponds to the end of a logical unit of work and to a point at which database is in a consistent state.
CITC
Vishwas Raval
Begin Transaction
T2
Rollback
Begin Transaction
T3
Commit
Transaction is unit also unit of recovery. If a transaction successfully commits, then the system will guarantee that its update will be permanently installed in the database, even if the system crashed the very next moment. It might be possible that system crash after the commit has been honored but before the updates have been physically written to the database they might still be
CITC
Vishwas Raval
The Write Ahead Log Rule: The log entry must be written physically before
COMMIT processing completes which is also known as Partial Commit. So, restart procedure will recover transactions that completed successfully but did not manage to get their updates physically written prior to crash. So, in this way, transactions are indeed the unit of recovery.
5. System Recovery
1. Local failure: Occurrence of an overflow condition within an individual transaction
is called local failure. For e.g. when a transaction is inserting data into the database and due to low size of the database transaction could not complete the insertion then it is a local failure. Local failure affects the transaction in which the failure has occurred actually.
2. Global failure: Power failure. Global failure affects all the transactions in progress
at the time of failure. Global failure is categorized into 2 broad categories: I) System failure and recovery:
CITC
Vishwas Raval
Tf
T1 T2 T3 T4 T5
Checkpoint
System Failure
The transaction of T1 will not enter into the restart process at all because it completed prior to Tc and its updates were forced to write into the physical database at the time checkpoint was taken as a part of checkpoint process. The transactions, which completed before Tf will also not enter in, restart process because those transactions changes would not have been made into the database.
CITC
Vishwas Raval
System goes forward first to undo the transactions and then goes backward to redo the transaction. Remember here, redoing the transaction means whole transaction will be performed from the scratch. This undo and redo processes are known as backward and forward recovery respectively. II) Media failure and recovery: It causes damage to the database or to some portion of it and affects at least those transactions currently using that portion. It is known as hard crash. For e.g. disk head crash, a disk controller failure in which some portion of database has been physically destroyed. Recovery form such failure involves reloading (restoring) the database from a back up copy (dump) and then using the log active and archive both. Here, no need to undo transactions that were still in progress at the time of failure, since by definition all updates of all such transactions would have been undone (actually lost). For media recovery there is a need for a dump utility. The dump portion of the utility is used to take backup on demand. It can be kept on tape or other archival storage media. So after failure, the restore portion of the utility is used to recreate the database from a specified backup copy.
CITC
Vishwas Raval
ii)
So now if failure occurs in system at some point during the overall process, the restart procedure will look for the decision record and based on the decision UNDO or REDO will take place. Here, data communication manager can also work as resource manager. Data communication manager is an autonomous system in its own rights but it should work in harmony with DBMS. Now, in case of distributed DBMS, where users workstation and DBMS are physically remote, then sending request to DBMS from end-user and responses back from the DBMS are transmitted in the form of messages. All such message transmission takes place under the control of DC manager.
CITC
Vishwas Raval