Schedules, serialisability and recoverability
How database schedules determine correctness (serialisability) and safe commit/abort behaviour (recoverability, ACA, strictness) and how to test them using precedence graphs and reads-from relations.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Two or three sentences: where an engineer uses this.
In concurrent transaction processing, an engineer must ensure that interleaved operations on shared data leave the database in a correct state. Understanding schedules, serialisability and recoverability lets you design or choose concurrency-control and recovery policies (locks, timestamps, logs, checkpoints, ARIES) so systems are correct and avoid costly cascading aborts or data loss.
Key ideas
Explain concepts from first principles, define terms before use.
Transaction: a sequence of database operations (reads, writes) that form a logical unit of work. Notation: transactions are Ti (T1, T2...).
Operation: a single action on a data item. We write a read of item X by Ti as r_i(X) and a write as w_i(X). Commit is c_i, abort is a_i.
Schedule (history): an ordering of operations from a set of transactions, respecting the order of operations within each transaction. A serial schedule executes all operations of one transaction, then all of the next, with no interleaving.
Serializable schedule: a schedule whose effect is equivalent to some serial schedule (serial schedules are trivially serializable and non-serial ones may be, too; gives the same final database state and same read results). Two important equivalence notions are conflict-equivalence and view-equivalence.
Conflict: two operations conflict if they are by different transactions, operate on the same data item, and at least one is a write. (So read–write, write–read and write–write on same item conflict.)
Conflict-serializability: a schedule is conflict-serializable if it is conflict-equivalent to some serial schedule. A common, efficient test is the precedence graph (also called serialization graph):
- Create one node for each transaction.
- Add a directed edge Ti -> Tj if some operation of Ti conflicts with a later operation of Tj in the schedule.
- The theorem: A schedule is conflict-serializable if and only if its precedence graph is acyclic.
Assumptions behind the theorem: operations are atomic and the conflict relation captures all cases that affect final state under a simple read/write model. University answers expect you to show how a topological order of an acyclic graph gives an equivalent serial order and vice versa: if the graph is acyclic, a topological sort produces a serial order consistent with all precedence edges; if there is a cycle, no serial order can satisfy all precedence constraints.
How to prove (standard exam derivation):
- If graph is acyclic, do a topological sort T_{i1}, T_{i2}, ...; by construction no edge goes from a later to an earlier node, so all conflicting pairs appear in schedule in the same order as in this serial order — hence conflict-equivalent.
- If a cycle exists, suppose there is a serial order; the cycle implies Ti must precede Tj, Tj must precede Tk, ... must precede Ti — impossible for a linear order. Therefore not conflict-serializable.
Diagram to draw in an answer: draw nodes labelled T1, T2,... and directed arrows for conflicting precedence (Ti -> Tj). Label each edge with the conflicting pair and data item, e.g. (r1(A) < w2(A)).
View-serializability: weaker notion. Roughly, a schedule is view-serializable if for each data item, the transactions that read the initial value or the later writes have the same "reads-from" relations as in some serial schedule and final writes produce the same final value. Checking view-serializability is harder (NP-complete). Conflict-serializable implies view-serializable, but not vice versa. However, if there are no blind writes (every write of X by a transaction is preceded by a read of X in that transaction), then view-serializability and conflict-serializability coincide.
Reads-from relation: we say Tj reads-from Ti for item X (i ≠ j) if Tj executes r_j(X) that returns a value produced by w_i(X) (not the initial value). This relation matters for recoverability.
Recoverable schedule: if Tj reads-from Ti, then Tj must not commit before Ti commits. More formally: for every pair (Ti, Tj) where Tj reads-from Ti, the commit c_i occurs before c_j.
Avoiding cascading aborts (ACA, "avoiding cascading aborts"): a schedule is ACA if every read operation reads only values written by committed transactions (so Tj never reads-from an uncommitted Ti). ACA implies recoverable (weaker requirement), because if reads are only from committed transactions, no read depends on an uncommitted transaction.
Strict schedule: stricter than ACA. A schedule is strict if whenever a transaction Ti writes X, no other transaction may read or write X until Ti commits or aborts. Strictness lets recovery be simple: undo actions can be applied without worrying about other transactions that read wrong values. Strict ⇒ ACA ⇒ Recoverable.
Relationship summary (theorems/exact statements):
- Conflict-serializability is decidable in polynomial time (via precedence graph). (Assume read/write model.)
- View-serializability includes more schedules but testing it is NP-complete (verify for your examiner if they expect the complexity claim). (State assumption: general read/write transactions.)
- Strict ⇒ ACA ⇒ Recoverable.
Two-phase locking (2PL): Basic 2PL produces conflict-serializable schedules; Strict 2PL produces strict (hence ACA and recoverable) schedules.
Formulas
Each formula on its own line, then symbol meanings and when it applies.
r_i(X) — read of data item X by transaction Ti. No SI unit. Use in operation sequences.
w_i(X) — write of data item X by transaction Ti.
c_i — commit of transaction Ti.
a_i — abort of transaction Ti.
edge(Ti -> Tj) iff ∃X and operations op ∈ Ti, op' ∈ Tj such that op and op' conflict on X and op occurs before op' in schedule — meaning build precedence/serialization graph edges by conflicting ordered pairs.
Conflict-serializable ⇔ precedence_graph is acyclic — applies to conflict-equivalence model of transactions with read/write operations.
Recoverable: ∀ Ti,Tj, (Tj reads-from Ti) ⇒ c_i before c_j — commit order must respect reads-from.
ACA (avoiding cascading aborts): ∀ r_j(X) that reads from w_i(X), c_i occurs before r_j(X) — read only committed values.
Strict: If w_i(X) occurs, then no r_j(X) or w_j(X) for j ≠ i occurs until c_i or a_i — write locks held until commit/abort.
Worked examples
Two university-exam standard examples.
Example 1 — conflict-serializability test (graph method) Schedule S1 (operations in order):
- r1(A)
- w2(A)
- r2(B)
- w1(B)
- c1
- c2
Step-by-step:
- List transactions: T1, T2.
- Find conflicts (different transactions, same item, at least one write):
- r1(A) conflicts with w2(A) (read–write on A) and r1(A) occurs before w2(A). So edge T1 -> T2.
- r2(B) conflicts with w1(B) (read–write on B) and r2(B) occurs before w1(B). So edge T2 -> T1.
- Draw precedence graph: nodes T1, T2 with edges T1 -> T2 and T2 -> T1.
- The graph has a cycle, so by the theorem the schedule is NOT conflict-serializable.
Final answer: S1 is not conflict-serializable. (It has a cycle T1↔T2.)
Note on recoverability for S1: determine reads-from relations. r1(A) reads initial value (there is no prior write to A by a transaction), r2(B) reads initial value (w1(B) happens after r2(B)). So no transaction reads from another transaction. Therefore commit order is not constrained by reads-from; S1 is recoverable. Summary: S1 — not conflict-serializable, but recoverable.
Example 2 — recoverability, ACA, strict Schedule S2a (recoverable):
- w1(A)
- r2(A) (reads-from w1(A))
- c1
- c2
Step-by-step:
- T2 reads-from T1 because r2(A) reads the value written by w1(A).
- Commits are c1 before c2, so the schedule satisfies the recoverable condition. Therefore S2a is recoverable.
Schedule S2b (not recoverable):
- w1(A)
- r2(A) (reads-from w1(A))
- c2
- c1
- T2 reads-from T1 but c2 happens before c1, violating the recoverable rule. If T1 later aborts, T2 would need aborting too; but T2 already committed — inconsistent. So S2b is not recoverable.
ACA vs Strict example:
- A schedule where r2(A) occurs only after c1 is ACA.
- If additionally no other transaction accesses A until c1 (i.e., writes are held locked until commit), the schedule is strict. Strict schedules make undo simple in recovery.
Final answers (bold):
- S2a is recoverable but not ACA (since r2 reads before c1). It is not strict (because T2 reads A before T1 commits).
- S2b is not recoverable.
Common mistakes
- Missing a conflict type: include read–write, write–read, and write–write. Only read–read does not conflict.
- Confusing "reads-from" (who supplied the value) with mere temporal order: a read that happens before a write does not read-from that write.
- Forgetting to label edges when explaining examples (exam answers should state which operations produced each edge).
- Claiming view-serializability is easy to test: it is computationally harder (NP-complete); verify if your course expects this complexity statement.
For your exam
Kinds of questions and what full-marks answers include:
- Definitions: define schedule, transaction, conflict, precedence graph, conflict-serializable, view-serializable, recoverable, ACA, strict. Give short examples.
- Short notes: pros/cons of conflict vs view serializability; relationship to lock-based protocols and timestamp methods (refer to related topics like lock-based concurrency control and timestamp-based control).
- Derivations / proofs: prove the precedence-graph theorem (acyclic ⇔ conflict-serializable) with a topological-sort style argument and the impossibility argument for cycles. Show strict⇒ACA⇒recoverable chain with formal statements.
- Numericals / traces: given a schedule, draw the precedence graph, decide conflict-serializable or not, decide recoverability/ACA/strictness, and give an equivalent serial order if serializable.
- Diagrams: draw the precedence graph with nodes and labeled edges; show reads-from arrows for recoverability questions. Label every edge with the pair of operations and the data item.
A full-marks answer: precisely define terms, show the step-by-step graph construction for example schedules, give the proof sketch where required, and clearly state final conclusions with reasons (e.g., "cycle T1->T2->T1 so not conflict-serializable").
Quick check
Three short questions:
- What is a conflict between two operations?
- How do you test conflict-serializability?
- What does ACA guarantee (in one line)?
Answers: 1. Operations on same data item by different transactions where at least one is write. 2. Build precedence (serialization) graph; schedule is conflict-serializable iff the graph is acyclic. 3. Every read reads only from values written by committed transactions (so no cascading aborts).
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?