So far, while studying serializability, we quietly assumed that every transaction commits. Real life is not so kind. Transactions abort all the time: a user cancels, a constraint fails, a deadlock victim is chosen, the system crashes.
When a transaction aborts, atomicity says all its changes must be undone. That sounds simple, until you realise that other transactions may already have read those changes. What happens to them? And what if one of them has already committed?
This chapter classifies schedules by how safely they handle aborts:
Irrecoverable schedules → an abort can leave the database in a state that cannot be fixed
Recoverable schedules → aborts can always be handled correctly, though possibly expensively
Cascadeless schedules → an abort never forces other transactions to abort
Strict schedules → an abort can be undone simply by restoring old values
Serializability is about correct interleaving when everyone commits. Recoverability is about staying correct when someone aborts.
We use the notation from the earlier chapters: R1(A), W1(A), C1 (T1 commits) and A1 (T1 aborts).
The Key Relationship: "Reads From"
Everything in this chapter depends on one idea:
Tj reads X from Ti if Tj reads X after Ti wrote X, and no other transaction wrote X in between. (Ti ≠ Tj.)
If Ti has not committed when Tj reads, Tj has performed a dirty read (from Schedules & Serializability). Tj now depends on Ti: if Ti aborts, the value Tj read never officially existed.
W1(A) ... R2(A) T2 reads A from T1 → T2 depends on T1
Irrecoverable Schedules
Let us start with the dangerous case. A = 5000. T1 debits ₹1,000 from A. T2 reads A and takes 20% of it. Then:
T1 T2 A
R(A) 5000
W(A) 4000 (uncommitted)
R(A) reads 4000 ← dirty read
W(A) 3200
COMMIT ← T2 is now permanent
ABORT ← T1 must be undone!
One-line form:
S1: R1(A) W1(A) R2(A) W2(A) C2 A1
Now the DBMS has a real dilemma:
Atomicity says T1's effects must disappear. But T2 based its write (3200) on T1's value (4000). To truly remove T1's effects, T2 must be undone too.
Durability says T2 has committed, so its effects must never be undone.
Both cannot be satisfied. The database is stuck with a value derived from a transaction that never happened. Such a schedule is called irrecoverable (or non-recoverable).
Note: S1 is conflict serializable (its precedence graph is just T1 → T2). Serializability does not protect you from this problem. That is why recoverability is a separate requirement.
Recoverable Schedules
A schedule is recoverable if, whenever Tj reads a data item from Ti, Ti commits before Tj commits.
In other words: a transaction may not commit until every transaction it read from has committed.
Let us fix S1 by delaying T2's commit:
S2: R1(A) W1(A) R2(A) W2(A) C1 C2
T2 reads A from T1, and C1 comes before C2 → recoverable ✓
Why does this help? Suppose T1 had aborted instead of committing. At that moment T2 has not committed yet, so the DBMS can still abort T2 as well. Nothing permanent was built on T1's dirty data.
S2': R1(A) W1(A) R2(A) W2(A) A1 → T2 not committed yet → abort T2 too → database clean ✓
How to check recoverability
Find every "Tj reads X from Ti" pair (Ti ≠ Tj).
For each pair, if Tj commits, check that Ti commits earlier.
If any reader commits before (or without) its writer committing, the schedule is irrecoverable.
Recoverability is the minimum requirement. Every practical DBMS must produce only recoverable schedules. But recoverable schedules can still be expensive, as we see next.
Cascading Rollback
In a recoverable schedule, one abort may force other aborts, and those may force more, like falling dominoes.
T1 T2 T3
R(A)
W(A)
R(A) T2 reads A from T1
W(B)
R(B) T3 reads B from T2
W(C)
ABORT
must abort (read T1's dirty A)
must abort (read T2's dirty B)
S3: R1(A) W1(A) R2(A) W2(B) R3(B) W3(C) A1
S3 is recoverable (no transaction committed after reading dirty data), so the situation can be fixed. But fixing it means rolling back T2 and T3 too. This is a cascading rollback (or cascading abort).
Why it is bad:
Wasted work: T2 and T3 did nothing wrong, yet all their work is thrown away.
Unpredictable cost: one abort can trigger a chain reaction across many transactions.
Bookkeeping: the DBMS must track who read from whom to know what to roll back.
Cascadeless Schedules
The cure for cascading rollback is to forbid dirty reads.
A schedule is cascadeless (also called ACA, "Avoids Cascading Aborts") if every transaction reads only values written by transactions that have already committed.
Formally: whenever Tj reads X from Ti, the commit of Ti must come before the read (not just before Tj's commit).
Fixing S3 means moving T1's commit before T2's read, and T2's commit before T3's read:
S4: R1(A) W1(A) C1 R2(A) W2(B) C2 R3(B) W3(C) C3
T2 reads A from T1 after C1 ✓
T3 reads B from T2 after C2 ✓
→ cascadeless
Now if any transaction aborts, nobody has read its uncommitted data, so only that one transaction rolls back.
Every cascadeless schedule is recoverable
If Tj reads from Ti only after Ti has committed, then Ti's commit certainly comes before Tj's commit (which happens after the read). So the recoverable condition holds automatically.
Cascadeless ⊂ Recoverable
The reverse is false: S2 (R1(A) W1(A) R2(A) W2(A) C1 C2) is recoverable, but T2 reads A before T1 commits, so it is not cascadeless.
Strict Schedules
Cascadeless schedules forbid dirty reads. But they still allow dirty writes: overwriting a value written by a transaction that has not yet finished. That causes a subtle problem for recovery.
Consider X = 10 initially:
S5: W1(X) W2(X) C2 A1
W1(X) T1 writes X = 20 (before-image saved: X was 10)
W2(X) T2 writes X = 30 (before-image saved: X was 20)
C2 T2 commits X = 30 is now permanent
A1 T1 aborts → undo T1 by restoring its before-image: X = 10 ✗
There are no reads at all, so S5 is trivially cascadeless (and recoverable). But undoing T1 in the usual way, by putting back its saved old value, would wipe out T2's committed write. The DBMS would need extra, complicated logic to realise that it must not restore X. (If the order were A1 then A2, a similar mess happens when restoring T2's before-image of 20, a value from an aborted transaction.)
A schedule is strict if no transaction reads or writes a data item X until the last transaction that wrote X has committed or aborted.
Under strictness, undo is trivial: to abort a transaction, just restore the before-image of each item it wrote. No other active transaction could have touched those items in the meantime.
S6: W1(X) C1 W2(X) C2 strict ✓ (T2 writes X only after T1 committed)
S7: W1(X) W2(X) C1 C2 cascadeless but NOT strict (dirty write)
Every strict schedule is cascadeless
Strictness forbids reading and writing uncommitted data. Cascadeless only forbids reading it. So strict is the stronger condition:
Strict ⊂ Cascadeless ⊂ RecoverableThe Complete Hierarchy
+----------------------------------------------------+
| All schedules |
| +--------------------------------------------+ |
| | Recoverable | |
| | (Ti commits before any Tj that read | |
| | from Ti commits) | |
| | +------------------------------------+ | |
| | | Cascadeless (ACA) | | |
| | | (read only committed data) | | |
| | | +----------------------------+ | | |
| | | | Strict | | | |
| | | | (no read or write of | | | |
| | | | uncommitted data) | | | |
| | | | +--------------------+ | | | |
| | | | | Serial | | | | |
| | | | +--------------------+ | | | |
| | | +----------------------------+ | | |
| | +------------------------------------+ | |
| +--------------------------------------------+ |
+----------------------------------------------------+
(A serial schedule is strict because each transaction commits or aborts before the next one starts.)
Class | Rule (Tj vs. an uncommitted writer Ti of X) | What it prevents |
|---|---|---|
Recoverable | Tj may read X, but must not commit before Ti commits | Committed transactions depending on aborted ones |
Cascadeless | Tj may not read X until Ti commits | Cascading rollbacks |
Strict | Tj may not read or write X until Ti commits or aborts | Complicated undo; dirty writes |
Recoverability and Serializability Are Independent
A very common exam trap is to assume one implies the other. They measure different things, and a schedule can be good on one and bad on the other:
Schedule | Conflict serializable? | Recoverability |
|---|---|---|
| Yes (T1 → T2) | Irrecoverable |
| No (T1 ⇄ T2 cycle) | Cascadeless (no reads of uncommitted data), not strict |
| Yes | Strict |
A DBMS needs schedules that are both serializable (for isolation) and at least recoverable, preferably strict (for atomicity and simple recovery).
The most widely used way to get both at once is strict two-phase locking: a transaction holds its exclusive (write) locks until it commits or aborts. This guarantees conflict-serializable and strict schedules. It is explained in Lock-Based Concurrency Control (2PL).
Seeing Strictness in MySQL
InnoDB keeps a transaction's row write locks until the transaction ends, so another transaction cannot overwrite a row that holds uncommitted changes. Let us watch it happen. T1 debits account 1, sleeps for 3 seconds, then rolls back. Half a second after T1 starts, T2 tries to add ₹500 to the same account:
-- T1
START TRANSACTION;
UPDATE accounts SET balance = balance - 1000 WHERE acc_no = 1;
SELECT SLEEP(3) INTO @x;
ROLLBACK;
-- T2 (starts while T1 is sleeping)
START TRANSACTION;
UPDATE accounts SET balance = balance + 500 WHERE acc_no = 1;
COMMIT;
While both are running, a third session looks at InnoDB's transaction list:
SELECT trx_state, trx_rows_modified, trx_query
FROM information_schema.innodb_trx ORDER BY trx_id;
+-----------+-------------------+--------------------------------------------------------------+
| trx_state | trx_rows_modified | trx_query |
+-----------+-------------------+--------------------------------------------------------------+
| RUNNING | 1 | SELECT SLEEP(3) INTO @x |
| LOCK WAIT | 0 | UPDATE accounts SET balance = balance + 500 WHERE acc_no = 1 |
+-----------+-------------------+--------------------------------------------------------------+
T2 is in LOCK WAIT: it is not allowed to write over T1's uncommitted change. After T1 rolls back, T2 proceeds and commits. Final result (starting from 5000):
+--------+--------+---------+
| acc_no | holder | balance |
+--------+--------+---------+
| 1 | Aarav | 5500.00 |
+--------+--------+---------+
₹5,000 + ₹500 = ₹5,500, exactly as if T1 had never run. Because T2 never wrote over dirty data, undoing T1 was as simple as restoring the old value. This is the strict-schedule idea in a real engine. (For reads, InnoDB avoids dirty reads at READ COMMITTED and above by showing readers the last committed version of the row, as we saw in Transactions & ACID Properties.)
Step-by-Step Classification Method
For each item X, for each write Wi(X), look at later operations on X by other transactions
before Ti commits/aborts:
1. Any Wj(X) or Rj(X) before Ti ends? No → STRICT (and so also ACA and recoverable)
2. Any Rj(X) before Ti commits? No → CASCADELESS (but not strict if step 1 failed)
3. For every such dirty read Rj(X):
does Ti commit before Tj commits? Yes → RECOVERABLE (but cascading aborts possible)
No → IRRECOVERABLE
Practice: Classify These Schedules
Try each one yourself before opening the answer. (All answers were checked with a small Python script that tests each definition directly.)
# | Schedule |
|---|---|
a |
|
b |
|
c |
|
d |
|
e |
|
f |
|
Show answers
# | Answer | Reason |
|---|---|---|
a | Recoverable, not cascadeless | T2 reads X from T1 before C1 (dirty read), but C1 comes before C2. |
b | Irrecoverable | T2 reads X from T1 and commits before T1 commits. |
c | Cascadeless, not strict | No dirty reads (T2 reads Y, which nobody wrote), but W2(X) overwrites T1's uncommitted X. |
d | Strict | No transaction reads from another. W2(X) comes after R1(X), but strictness only restricts access to items whose writer is still active, and T1 never writes X. |
e | Irrecoverable | T2 reads X from T1 and commits (C2) before T1 commits (C1). |
f | Strict | T2 reads X from T1 only after C1; no one else writes Y. |
Common Mistakes
Checking the read against the commit for recoverability. Recoverable only needs Ti to commit before Tj commits. "Before Tj reads" is the stronger cascadeless condition.
Forgetting dirty writes. A schedule with no reads at all can still be non-strict, as in
W1(X) W2(X) C1 C2.Assuming serializable means recoverable. They are independent; check both.
Counting a transaction reading its own write as a dirty read. "Reads from" only concerns different transactions.
Forgetting the case where the writer never commits. If Tj read from Ti and Tj commits, but Ti aborts (or has still not committed when the schedule ends), the schedule is irrecoverable. The rule needs Ti's commit to come first, not just Ti's last operation.
Interview Questions
1. What is a recoverable schedule?
One in which, if Tj reads data written by Ti, then Ti commits before Tj commits. This ensures no committed transaction depends on an aborted one.
2. Why is an irrecoverable schedule dangerous?
If the writer aborts after the reader has committed, atomicity requires undoing the reader, but durability forbids undoing a committed transaction. The database can be left inconsistent.
3. What is a cascading rollback?
When one transaction's abort forces other transactions that read its uncommitted data to abort, which can in turn force further aborts.
4. How do cascadeless schedules avoid it?
By allowing transactions to read only committed data. Then an abort never affects anyone else.
5. Difference between cascadeless and strict?
Cascadeless forbids reading uncommitted data. Strict also forbids writing over uncommitted data, so undo can be done simply by restoring before-images.
6. Arrange recoverable, cascadeless, strict and serial in order of inclusion.
Serial ⊂ Strict ⊂ Cascadeless ⊂ Recoverable.
7. Which protocol gives schedules that are both conflict serializable and strict?
Strict two-phase locking, which holds exclusive locks until commit or abort.
Summary
Tj reads from Ti → Tj depends on Ti's write; if Ti is uncommitted, this is a dirty read.
Irrecoverable → a reader commits before the writer it read from; an abort can leave permanent damage.
Recoverable → writers commit before their readers commit; aborts can be handled, but may cascade.
Cascadeless (ACA) → read only committed data; no cascading rollbacks.
Strict → neither read nor write data whose writer is still active; undo is simply "restore the before-image".
Serial ⊂ Strict ⊂ Cascadeless ⊂ Recoverable, and recoverability is independent of serializability.
Strict 2PL (holding write locks until commit or abort, as InnoDB does for row locks) gives schedules that are both conflict serializable and strict.
In the next chapter, Lock-Based Concurrency Control (2PL), we will see how locking protocols actually produce such safe schedules.