Transaction States in DBMS

States through which a transaction goes during its lifetime are known as transaction states in DBMS. These states tell about the current state of the Transaction.



Types Of Transaction States

There are six major types of Transaction states, which  are given below

  1. Active state
  2. Partially committed state
  3. Committed state
  4. Failed state
  5. Aborted state
  6. Terminated state

A detailed diagram of the transaction is stated below

1. Active State

  • The transaction is in the Active state when its instructions are being executed.

  • It will stay in this state as long as the transaction is processing.

  • If the transaction completes successfully, it moves to the Partially Committed state. If a failure occurs, it transitions to the Failed state.

2. Partially Committed State

  • After all instructions are executed, the transaction enters the Partially Committed state.

  • In this state, the changes made by the transaction are stored temporarily in the main memory (buffer).

  • The transaction may either succeed and move to the Committed state or fail, leading to a Failed state.

3. Committed State

  • In this state, the changes made by the transaction are permanently stored in the database.

  • The transaction is considered complete, and the modifications are saved to disk, making the changes durable and irreversible.

4. Failed State

  • A transaction enters the Failed state if an error occurs during the Active or Partially Committed states, making it impossible to continue.

  • At this point, the transaction cannot return to Active or Partially Committed states. It needs to be dealt with through a rollback.

5. Aborted State

  • If a transaction fails, it can enter the Aborted state.

  • The Rollback process is used to undo any changes made by the transaction up to this point, ensuring that the database returns to its original state before the transaction started.

  • After rollback, the transaction may be restarted from the beginning if needed.

6. Terminated State

  • This is the final state of a transaction after it has either committed or aborted.

  • Once a transaction is either fully committed or aborted, it enters the Terminated state, indicating that no further operations will be performed, and the transaction is complete.

Conclusion

Understanding the transaction states in DBMS helps in managing the execution of transactions and ensuring that the database remains consistent, reliable, and free from errors. Whether a transaction completes successfully or fails, the DBMS handles the transition through various states (Active, Partially Committed, Committed, Failed, Aborted, and Terminated) to ensure that all operations are safely executed and rolled back if necessary.