Database transaction states in DBMS, different states a transaction can go through in DBMS, Active, Partially committed, Committed, Failed, and Aborted states, Various transaction states, explain various transaction states in dbms with example
|State Transition Diagram of states of transaction execution|
Active state – Initial state.
Partially committed state – After the execution of final statement.
Committed – After successful completion of transaction.
Failed – If any failure occurs.
Aborted – After rolled back to the old consistent state.
A := A - 500;
B := B + 500;
- ACTIVE - When the transaction T1 starts, i.e., enters BEGIN TRANSACTION, the transaction in ACTIVE state. From BEGIN TRANSACTION and COMMIT, the transaction is in ACTIVE state only.
- In ACTIVE state, A = 1000 and B = 1000.
- PARTIALLY COMMITTED - If T1 reaches the instruction COMMIT, the transaction goes into PARTIALLY COMMITTED state.
- In PARTIALLY COMMITTED state, A = 500 and B = 1500;
- FAILED – It happens if one of the following occurs;
- If the transaction failed before WRITE(A), then A = 1000 and B = 1000.
- If the transaction failed after WRITE(A), then A = 500 and B = 1000.
- If the transaction failed before COMMIT and after WRITE(B), then A = 500 and B = 1500.
- If any failures happen to the transaction in PARTIALLY COMMITTED state (refer type of failures) then the transaction goes into FAILED state.
- If the transaction goes into FAILED state from PARTIALLY COMMITTED state, then A = 500 and B = 1500.
- ABORTED - The transaction in ABORTED state has to undo the changes made so far. That is the old consistent values of data items A and B are restored.
- In ABORTED state, A = 1000 and B = 1000. [A and B are rolled back to Old consistent state]
- COMMITTED - If the transaction executes COMMIT successfully, that is, if it successfully writes the new value of A and B into log file or stable storage, then the transaction is said to be in COMMITTED state.
- In COMMITTED state, A = 500 and B = 1500. [New consistent state]