Intro to DBMS

Transaction States in DBMS

States through which a transaction goes during its lifetime are known as transaction states. 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

  • When the instructions of the transaction are executed, then the transaction is in an active state.
  • In case of execution of all instructions of the transaction, the transaction can go to the “partially committed state”; otherwise, it can go to the “failed state” from the active state.

2. Partially Committed State

  • After the execution of all instructions of a transaction, the transaction enters into a partially committed state from an active state.
  • At this stage, changes are still possible in the transaction because all the changes made by the transaction are still stored in the buffer of the main memory.

3. Committed State

  • The committed state permanently stores all changes made by the transaction in the database
  • Now, the transaction is considered fully committed.

4. Failed State

  • When a transaction is in the “active state” or “partially committed state” and some failure occurs, then it becomes impossible to resume its execution, So it enters into a failed state.

Note: At this stage, the Transaction cannot go to a “partially committed state” or “active state”.

5. Aborted State

  • As we know, a failed state can never be resumed, but it is possible to restart the failed transaction. To restart the failed transaction, the Rollback method comes into the picture.
  • When we roll back (restart) the failed transaction, all the changes made by that transaction earlier have to be undone.

6. Terminated State

  • This is the last stage of the transaction in its life cycle.

If any transaction comes from an “Aborted state” or “committed state,” then that transaction is terminated and ready to execute the new transactions.