Skip to content

Transaction States

A transaction goes through several states from start to finish (or failure).

The 5 Transaction States

1. Active

Transaction is currently executing. Initial state when transaction begins. Read/Write operations are happening.

2. Partially Committed

Last operation has been executed, not yet saved. All operations are done. Changes are still in buffer/memory, not on disk yet. System checks if commit is possible.

3. Committed

Changes are permanently saved to disk. COMMIT executed successfully. Durable and visible to others. Cannot go back from here.

4. Failed

Transaction cannot proceed. Something went wrong during Active or Partially Committed state (system crash, constraint violation, deadlock, manual ROLLBACK).

5. Terminated (Aborted)

Transaction is rolled back and done. ROLLBACK has been executed. DB restored to state before the transaction. Can be restarted or killed.

State Diagram

BEGIN --> [ACTIVE]
             |
        all ops done
             |
   [PARTIALLY COMMITTED]
      /              \
 commit OK        commit fail
    /                    \
[COMMITTED]           [FAILED]
                          |
                      rollback
                          |
                     [ABORTED]
                          |
              .-----------.-----------.
              |                       |
        Restart TX               Kill TX

State Transition Table

FromToTrigger
ActivePartially CommittedAll operations done
ActiveFailedError / crash
Partially CommittedCommittedSuccessful COMMIT
Partially CommittedFailedDisk write fails
FailedAbortedROLLBACK completes
AbortedActiveTransaction restarted