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
- Atomicity: all or nothing (recovery undoes partial work).
- Consistency: valid state to valid state (the programmer's job).
- Isolation: concurrent transactions do not interfere (concurrency control).
- 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.
- 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).
| Property | Meaning | Component that provides it |
|---|---|---|
| Atomicity | all operations happen or none do | recovery manager (undo) |
| Consistency | database moves from one valid state to another | the programmer and integrity constraints |
| Isolation | concurrent transactions do not see each other's partial work | concurrency control (locks, timestamps) |
| Durability | committed changes survive a crash | recovery manager (redo, logging) |
Check yourself
A transaction that finished its last statement but whose changes are not yet made permanent is in state
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.