Skip to content
We areTOP 1%

What are the different states of a transaction?

EasyConceptTransactions & ACID
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

A transaction moves through five states: active, partially committed, committed, failed and aborted. It starts in the active state and ends either committed or aborted.

  • Active to partially committed: the transaction executes its reads and writes; once its last statement has run, it is partially committed, although the changes may still be only in memory.
  • Partially committed to committed: the commit record is written to the log on disk, so the changes become permanent.
  • Failed to aborted: an error, a constraint violation or a crash moves it to failed; after all its changes are rolled back, it is aborted, and the DBMS can restart it or kill it.
  • A committed or aborted transaction is said to be terminated.

Example: Booking a train seat:

Active              -> seat marked, payment in progress
Partially committed -> last UPDATE done, COMMIT issued
Committed           -> commit record written; booking confirmed
(or) Failed         -> payment declined
Aborted             -> ROLLBACK releases the seat

More in Transactions & ACID

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account