In this guide, we will discuss the states of a transaction in DBMS. A transaction in DBMS can be in one of the following states.
DBMS Transaction States Diagram
Lets discuss these states one by one.
Active State
As we have discussed in the DBMS transaction introduction that a transaction is a sequence of operations. If a transaction is in execution then it is said to be in active state. It doesn’t matter which step is in execution, until unless the transaction is executing, it remains in active state.
Failed State
If a transaction is executing and a failure occurs, either a hardware failure or a software failure then the transaction goes into failed state from the active state.
Partially Committed State
As we can see in the above diagram that a transaction goes into “partially committed” state from the active state when there are read and write operations present in the transaction.
A transaction contains number of read and write operations. Once the whole transaction is successfully executed, the transaction goes into partially committed state where we have all the read and write operations performed on the main memory (local memory) instead of the actual database.
The reason why we have this state is because a transaction can fail during execution so if we are making the changes in the actual database instead of local memory, database may be left in an inconsistent state in case of any failure. This state helps us to rollback the changes made to the database in case of a failure during execution.
Committed State
If a transaction completes the execution successfully then all the changes made in the local memory during partially committed state are permanently stored in the database. You can also see in the above diagram that a transaction goes from partially committed state to committed state when everything is successful.
Aborted State
As we have seen above, if a transaction fails during execution then the transaction goes into a failed state. The changes made into the local memory (or buffer) are rolled back to the previous consistent state and the transaction goes into aborted state from the failed state. Refer the diagram to see the interaction between failed and aborted state.
Harsha Chowdary says
I have a doubt in partially commited state you told that this state help us to rollback the changes made to the database in case of a failure during Execution,but actually the changes should be made to the data stored in main memory right,so that in case if any failure occurs ,it rollbacks(acquires) the previous value from the database