Transaction States in DBMS: State Diagram, Worked Example and Exam Traps

Trace one database transfer from active to committed, then see exactly what changes when failure strikes before the commit decision becomes durable.

KnowledgeGate Team

Exam prep & CS education

Updated 5 Dec 20266 min read
Transaction States in DBMS: State Diagram, Worked Example and Exam Traps

Finishing the last statement of a transaction is not the same event as committing it. Detecting a failure is not the same as completing rollback. In a 300-unit transfer, the success path and both rollback paths preserve the total 2800, but they cross different transaction-state boundaries. For the wider subject route, use CS Fundamentals.

What a transaction state tells you

A transaction is one logical unit of database work. Its state is the DBMS's current progress and recovery classification for that unit. The state tells us what has finished, whether useful work may continue, whether rollback is still pending, and whether a successful outcome is durable.

The six standard teaching states are active, partially committed, committed, failed, aborted, and terminated. Some diagrams omit terminated or fold cleanup into the committed and aborted endpoints, so use the states and arrows supplied in the question.

Transactions and Concurrency Control in DBMS owns the broader foundation: ACID, schedules, serializability, locking, and isolation anomalies. A transaction-state problem is narrower: identify the event that moves one attempt across each lifecycle boundary.

The six transaction states and their boundaries

State

What is true

What is not yet true

Active

Instructions are executing.

Success is not settled.

Partially committed

The final statement has executed.

The commit outcome is not yet durable.

Committed

The commit point has been crossed.

Lifecycle cleanup may still remain.

Failed

Normal execution cannot continue.

Undo may still be pending.

Aborted

Rollback has completed and the transaction's effects have been removed.

This attempt has not succeeded.

Terminated

The DBMS has finished the lifecycle and released or discarded remaining bookkeeping resources.

No lifecycle work remains for this attempt.

The key separations are simple: partially committed is not committed, failed is not aborted, and committed does not merely mean all statements ran. Physical protocols vary. Conceptually, a durable commit decision means the successful outcome must survive later failure.

Worked success path: transfer 300 with exact values

Transaction T1 transfers 300 from A to B. Initially, A=2000 and B=800, so the invariant is A+B=2800. Follow the exact operation trace:

Event

State after the event

Values or durable record

BEGIN T1

Active

A=2000, B=800, A+B=2800

Read A, compute 2000 - 300, log and write A=1700

Active

<T1,A,2000,1700>

Read B, compute 800 + 300, log and write B=1100

Active

<T1,B,800,1100>

Final statement completes

Partially committed

A=1700, B=1100, A+B=2800

Append <T1,COMMIT>

Partially committed until the record is durable

Commit record not yet durable

Make the commit record durable

Committed

The successful outcome must survive a later failure

Release locks and bookkeeping

Terminated

No lifecycle work remains for this attempt

From BEGIN through both writes, T1 is active. After the final statement, it is partially committed with A=1700, B=1100, and 1700+1100=2800, but success is not durable. Appending <T1,COMMIT> does not change that state. When the record becomes durable, T1 is committed. Cleanup releases locks and transaction-table bookkeeping, then it is terminated.

Write-ahead logging gives two narrow guardrails. An update log record must be durable before its corresponding dirty page is written. The commit decision must be durable before success is acknowledged. This does not require every changed data page to be on disk at commit.

State-transition diagram for transaction T1 shows A=1700, B=1100, total=2800, with success through COMMITTED and TERMINATED and failure paths through FAILED and ABORTED.

Two failure branches from the same transfer

Failure A occurs immediately after write(A=1700), before B changes. The sequence is active -> failed -> aborted. Failure stops normal execution but restores nothing. Rollback uses <T1,A,2000,1700> to undo A from 1700 to 2000. B remained 800. After undo, T1 is aborted with A=2000, B=800, and 2000+800=2800.

Failure B occurs after write(B=1100) and the final statement, but before <T1,COMMIT> is durable. T1 is partially committed just before failure, then failed. Rollback undoes B from 1100 to 800, followed by A from 1700 to 2000. It is then aborted. This proves why partial commitment remains vulnerable.

Failure point

State just before failure

Undo required

State after rollback

Final A,B,total

After write(A=1700)

Active

A: 1700 -> 2000

Aborted

2000,800,2800

After final statement, before durable commit

Partially committed

B: 1100 -> 800; A: 1700 -> 2000

Aborted

2000,800,2800

If policy permits a retry, call it T1', a new active attempt. Otherwise, the aborted attempt proceeds to terminated. The old attempt does not magically become committed.

Three-lane timeline compares transaction T1’s success, active-failure, and partial-commit-failure paths, with A+B=2800, final values A=1700 and B=1100, and rollback outcomes to A=2000 and B=800.

Read each valid transition as event plus consequence

The success edges are active -> partially committed when the last statement finishes, partially committed -> committed when the commit decision becomes durable, and committed -> terminated after cleanup. Neither partial commit nor termination is an SQL command in this model.

An error, deadlock-victim choice, explicit abort, constraint failure, or system failure can send an active transaction to failed. A partially committed transaction also fails if durability is not secured. The edge failed -> aborted is crossed only when rollback finishes. Policy may then terminate the attempt or restart the work as a fresh attempt.

After a durable commit, a crash does not move T1 backwards to failed. Recovery must preserve or redo its committed effect, even when every changed data page had not yet been flushed.

Common transaction-state traps and corrections

  1. Calling T1 committed after write(B=1100). The business calculation is complete, but the durable commit boundary is missing. The correct state after the final statement is partially committed.

  2. Treating failed and aborted as synonyms. Failed means normal work cannot continue. Aborted means rollback is complete.

  3. Requiring every changed page on disk before commit. That confuses durability with forcing all pages and ignores WAL-based recovery. Use the durable commit decision as the conceptual boundary.

  4. Drawing committed -> failed or failed -> committed. Failure before durable commit requires rollback. Failure after durable commit requires recovery to preserve the committed result.

  5. Making aborted a compulsory dead end. Read the supplied diagram. It may permit a new retry or termination.

How transaction-state diagrams become questions

A question may hide one state or arrow, name an event and ask for the state, offer a set of transitions, contrast failed with aborted, or ask which values survive a crash. The deciding step is always the same: locate the event relative to the final statement, durable commit, rollback completion, and cleanup.

Use five answer-first checks from T1:

  • After the final write but before durable commit: partially committed.

  • After an error but before undo completes: failed.

  • After A and B return to 2000 and 800: aborted.

  • After the commit record becomes durable: committed.

  • After a later crash: recovery preserves 1700 and 1100 for the committed attempt.

DBMS Transaction MCQs: 12 Solved uses sourced questions to test ACID, serializability, recoverability, and locking. DBMS Interview Questions for Freshers turns the same vocabulary into concise verbal checks. State-diagram problems remain narrower: identify the exact boundary event and the values that survive it.

The short version and the next step

The success chain is active -> partially committed -> committed -> terminated. The failure chain is active or partially committed -> failed -> aborted -> retry or terminate. Remember the two boundaries: the last statement finishing does not make the commit durable, and detecting failure does not mean rollback is complete.

Redraw the T1 diagram from memory and recompute both failure branches. For a structured route through DBMS and the rest of GATE CS, use GATE Guidance by Sanchit Sir.