Transaction State Diagram
Transaction State Diagram
Let us understand all the states in terms of stages in detail:
Stage-1: Once a transaction becomes active it starts its execution and goes to active state. It chooses read or write operations in this stage and stays here till the transaction is executed.
Stage-2: Once the read and write operation completes successfully, the transaction then goes to partially committed state, where all the read and write operations are performed on the local memory instead of actual database.
The reason for having this state is that, the transaction may fail during execution, and may lead actual database instead of local memory, in an inconsistent state in case of failure. So having this state can help us rollback the changes made to the database in case of execution failure.
Stage-3: Then, it is responsibility of recovery protocol, to ensure that a system failure will not disable permanent changes to the database. It any failure occurs either software failure or hardware failure, then the transaction goes to the failed state from the active state.
Stage-4: If a transaction completes the execution successfully then all the changes made in local memory during partially committed state are permanently stored in the actual database. Then the transaction goes to the committed state on successful execution of transaction.
Stage-5: At the end, from committed or failed state the transaction goes to terminated state, from where the transaction cannot be restarted.
Comments
Post a Comment