← 🔀 Transactions & Concurrency Control
Subtopic 1 of 7

6.1Transactions, ACID and states

The idea

A transaction is a group of operations that must succeed or fail as one. ACID lists the guarantees: Atomicity, Consistency, Isolation, Durability.

Think of it like this: Transferring money: debit and credit either both happen or neither does.

Why it exists

ACID properties and transaction states are easy theory marks.

How it works

  1. Atomicity: all or nothing (recovery undoes partial work).
  2. Consistency: valid state to valid state (the programmer's job).
  3. Isolation: concurrent transactions do not interfere (concurrency control).
  4. Durability: committed work survives crashes (logging and redo).

Worked example: Which component enforces durability?

The recovery manager, through the log and redo of committed work.

Now play with it

  • →Step through the state diagram.
  • →Match each ACID property to its component in the table.
last statement donechanges made permanenterrorwrite failsrollbackActivePartially committedCommittedFailedAborted
  • Transaction starts: Active (it is executing reads and writes).
  • Its last statement is executed: Partially committed (the changes may still be only in memory).
  • The log and data are safely on disk: Committed. This is the only way to finish successfully.
  • Alternatively an error happens while Active (or a write fails when Partially committed): Failed.
  • The system rolls the work back and the transaction ends: Aborted (it may then be restarted or killed).
PropertyMeaningComponent that provides it
Atomicityall operations happen or none dorecovery manager (undo)
Consistencydatabase moves from one valid state to anotherthe programmer and integrity constraints
Isolationconcurrent transactions do not see each other's partial workconcurrency control (locks, timestamps)
Durabilitycommitted changes survive a crashrecovery manager (redo, logging)

Check yourself

A transaction that finished its last statement but whose changes are not yet made permanent is in state

Remember: ACID: Atomicity, Consistency, Isolation, Durability.
Exam notes (the dense version)

A transaction is a logical unit of work. ACID: Atomicity (all or nothing; handled by recovery), Consistency (moves the database between valid states; the programmer's duty), Isolation (as if run alone; concurrency control), Durability (committed changes survive crashes; logging). States: active → partially committed → committed, or active/partially committed → failed → aborted.

Previous year questions: Transactions & Concurrency Control (15)

PYQs are grouped by topic, so this is the full set for Transactions & Concurrency Control; try the ones that match this subtopic. Open all 15 on the topic page.