Schedules: draw the order, test the graph

Read an interleaved transaction schedule, draw its conflict edges, and separate serializability from recovery safety. Schedules and concurrency control · Databases.

Two transfers touch the same two items. Each transaction is reasonable when run alone, but an interleaving can impose two opposite orders at once. You will read the operations first, then draw only the relationships the schedule actually creates.

Put each operation in one history

A schedule is one total order of operations that preserves the order inside each transaction. A serial schedule runs one transaction to completion before the next begins. A concurrent schedule interleaves operations while preserving each transaction's own order. For this lesson, conflict serializability means that the schedule's relevant read/write observations and resulting values can match some serial order while preserving every conflict order. It does not mean the database executed serially, and it is not a promise that every committed attempt has the same visible history.

Mark only cross-transaction conflicts

Two operations from different transactions conflict when they touch the same item and at least one is a write. Read-read pairs do not conflict. For every conflicting pair, preserve the order shown in the schedule and draw an edge from the earlier operation's transaction to the later operation's transaction.

The primary history is r1(A); w1(A); r2(A); w2(B); c1; c2. The pair w1(A) before r2(A) gives T1 → T2. The read of A and write of B are different items, and operations inside one transaction do not create an inter-transaction edge. The graph has one direction and no cycle, so this history preserves its relevant conflict order, observations and values under the candidate serial order T1 then T2.

Draw one conflict edge, then test the graph

Read the steps as text

  1. The merged history preserves each transaction's internal order. Initial A is 10 and B is 20; no relationship is drawn yet.
  2. T1 and T2 are interleaved while each transaction keeps its own order, so this is a concurrent schedule.
  3. w1(A) precedes r2(A) on the same item, and at least one operation writes, so the schedule contributes T1 to T2.
  4. The graph has one direction and no cycle. Its matching candidate serial order is T1 then T2, even though the displayed work was interleaved.
  5. The acyclic graph preserves the relevant conflict order under candidate serial order T1 then T2; recovery timing is a separate check.

The first frame gives the merged history and its initial values. Use r1(A) for T1 reading item A, w2(B) for T2 writing B, and c1 for T1 committing. Identify the interleaving, then decide whether w1(A) and r2(A) conflict and which edge it creates. The final step shows the acyclic graph and names the matching serial order. The conclusion is about this finite conflict-serializability test, not a universal claim about every notion of serializability.

Let a cycle reject the candidate

The faded history changes the order to r1(A); r2(B); w1(B); w2(A); c1; c2. Now r1(A) before w2(A) gives T1 → T2, while r2(B) before w1(B) gives T2 → T1. Those two edges form a cycle. No serial order can preserve both conflict directions, so this history is not conflict-serializable. This graph test alone does not rule out view serializability, which uses a broader equivalence criterion.

Trace a second transaction history

Read the steps as text

  1. The faded history is fully stated first: initial A is 10 and B is 20, with both transactions committing after their writes.
  2. r1(A) precedes w2(A), so the first revealed conflict edge points from T1 to T2.
  3. r2(B) precedes w1(B), adding T2 to T1. The second edge closes the opposite direction, but the result is held for the next reveal.
  4. The graph contains a cycle, so no serial order can preserve both conflict directions in this selected conflict test.

The second frame carries the two operation pairs into a graph. Follow the first edge, then the second edge, as the cycle is revealed. A cycle is the decisive result for the conflict test; do not erase an edge because the final values happen to look plausible.

Check recovery safety separately

The graph answers a serial-order question. Commit and visibility rules answer what happens if a transaction aborts. If T2 reads a value written by T1, a recoverable schedule requires c1 before c2; otherwise T2 could commit a value that T1 later aborts. Recoverability still permits T2 to read before c1, so an abort can force a cascading rollback.

A cascadeless schedule delays that read until T1 commits or aborts. If T1 commits, T2 may observe T1's committed value; if T1 aborts, T1's write disappears and T2 proceeds only from a surviving committed or old version. A strict schedule applies the same visibility rule and also delays writes of the item until T1 commits or aborts, so no later write overwrites an unresolved value. Thus the selected hierarchy is strict ⊂ cascadeless ⊂ recoverable; these properties complement the conflict graph rather than replacing it.

Check commit and visibility timing separately

Read the steps as text

  1. Both candidates and the abort branch are explicit. A starts at 10; the question is when a read or write may rely on T1's unresolved value.
  2. In the first candidate, c1 precedes c2, so T2 cannot commit before the transaction whose value it read. That is recoverable, but the read was early.
  3. If T1 aborts before T2 reads, T1's write is discarded before that read. T2 therefore reads the surviving old committed value A = 10.
  4. The second candidate delays both the dependent read and the later write until c1. It is strict, and therefore also cascadeless and recoverable.
  5. Recovery properties are checked from commit, read and write timing separately from the conflict graph; strict is the strongest selected case.

The recovery frame compares w1(A); r2(A); c1; c2 with w1(A); c1; r2(A); w2(A); c2. The first is recoverable but neither cascadeless nor strict because T2 reads before T1 commits. The second is strict, and therefore also cascadeless and recoverable. Inspect the read-from and commit points, then the write timing, instead of using the graph result as a shortcut. If T1 aborts before T2 reads, its write is discarded and T2 sees only the surviving committed or old version.

Recap

  • A concurrent schedule interleaves ordered transaction operations; under this conflict test, serializability means its relevant read/write observations and resulting values match a serial order, not serial execution.
  • Conflict edges come only from cross-transaction same-item pairs with a write; an acyclic precedence graph passes the conflict-serializability test.
  • Recoverable, cascadeless and strict rules constrain commit, read and write timing at different strengths after a shared write.
The boundary before locking and timestamp protocols

This prerequisite stops at schedule reasoning. The Locks, two-phase locking, and deadlock handling lesson teaches shared/exclusive compatibility, growing and shrinking phases, strict 2PL and wait-for cycles. The Timestamp ordering and the Thomas write rule lesson teaches timestamp rules and a qualified Thomas write rule as a separate non-locking protocol. Neither mechanism is silently folded into this graph lesson, and neither protocol is required to decide the finite edge examples above.

Next: Locks, two-phase locking, and deadlock handling applies a protocol to the schedules this lesson classifies.

For a DSA connection, Queue Fundamentals gives you a compact way to trace an ordered event history; keep queue operations separate from serializability.