19.2 KB · commit 40bb182
← Previous: T10.4: Building Serializable and Non-Serializable Schedules | 🏠 Index | Next: T10.6: Recoverable, Cascadeless, and Strict Schedules →
Topic: T10 — Serializability | Priority: 🟢 | Exam Frequency: 1/7 finals (6 marks) Sources: Silberschatz 7e Ch. 18 (§18.5 Note 18.1, p. 867) · Lecture Deck 07 (Slides 22–23, 27) · Raidah Notes (p. 27–28)
Conflict serializability is fast to test with a precedence graph, but it is sometimes too strict. Because conflict serializability cares only about whether conflicting instructions can be swapped, it rejects certain schedules that are actually 100% safe and produce the exact same result as a serial run. This happens when transactions perform blind writes, which means writing to a data item without reading it first. View serializability looks at what really matters for correctness: which values each transaction reads and which transaction writes the final value to the database. Tested in 2020 Q.6(b) for 6 marks, this topic is a favorite for testing both your conceptual understanding of blind writes and your ability to verify the three view-equivalence rules step by step.
View Equivalence: Two schedules S and S′ over the same set of transactions are view equivalent if they satisfy three conditions for every data item Q:
- Initial Read: If transaction Ti reads the initial value of Q in S, then Ti must also read the initial value of Q in S′.
- Updated Read (Read-From): If transaction Ti reads a value of Q written by Tj in S, then Ti must read the value produced by that exact same write(Q) operation of Tj in S′.
- Final Write: The transaction that performs the final write(Q) at the end of S must also perform the final write(Q) in S′.
View Serializability: A schedule S is view serializable if it is view equivalent to some serial schedule. Every conflict-serializable schedule is automatically view serializable, but some view-serializable schedules with blind writes are not conflict serializable.
Blind Write: A blind write is a write(Q) operation executed by a transaction without having read data item Q first. Every schedule that is view serializable but not conflict serializable must contain at least one blind write.
Instead of asking "Can I swap adjacent steps?", view equivalence asks a much simpler question: "Does every transaction see the exact same data, and does the database end up with the exact same final values?"
Suppose S is a concurrent schedule and S′ is a candidate serial schedule over the same transactions. To check if S and S′ are view equivalent, we check three rules for every data item Q:
If transaction Ti reads the original starting value of Q in S (before anyone has written to Q), then Ti must also read the original starting value of Q in S′.
If transaction Ti reads a value of Q that was written by transaction Tj in S, then Ti must read the value produced by that exact same write(Q) of Tj in S′.
If transaction Tk performs the very last write(Q) at the end of schedule S, then Tk must also perform the very last write(Q) in S′.
Together, Rules 1 and 2 guarantee that every transaction reads the exact same inputs in both schedules (so it computes the exact same values), while Rule 3 guarantees that the final value left on disk for Q is identical when everyone finishes.
A blind write is a write(Q) operation performed by a transaction that never executed read(Q) first:
T2: write(Q); -- Blind write: T2 overwrites Q without ever reading Q first
In most everyday transactions, a write depends on an earlier read (such as read(Q); Q := Q + 100; write(Q)). In a blind write, the transaction simply stamps a new value onto Q (like resetting a status flag or setting Q := 0) without looking at what was stored in Q before.
Imagine three people sharing an office whiteboard Q that starts with the number 10:
read(Q)) and sees 10, then starts doing some math at their desk.99 (write(Q)).99, T1 walks back up, erases 99, and writes 25 (write(Q)).25, and writes 500 (write(Q)).Now ask yourself: Did T2's write of 99 have any effect on anyone?
99, and T1 and T3 immediately wiped it out. Whether T2 wrote 99 before T1's write or after T1's write, T1 still read 10 at the beginning and T3 still left 500 on the board at the end!Key Rule to Remember: Every view-serializable schedule that is not conflict serializable must contain at least one blind write. If a schedule has no blind writes at all, conflict serializability and view serializability give the exact same answer.
| Feature | Conflict Serializability | View Serializability |
|---|---|---|
| Core Idea | Preserves the order of all conflicting pairs (R-W,W-R,W-W) | Preserves initial reads, read-from pairs, and final writes |
| How We Test It | Precedence graph cycle check | Check the 3 view rules against candidate serial orders (NP-complete in general) |
| Time Complexity | Fast: O(V+E) polynomial time | Slow: Exponential time in the worst case |
| How Strict Is It? | Stricter (a smaller subset of schedules) | Broader (accepts safe schedules with blind writes) |
| Blind Writes | Rejects safe schedules if an unread blind write creates a cycle | Accepts them as long as the 3 view rules hold |
| Real-World DBMS Use | Used by standard 2PL lock managers and basic timestamp ordering | Theoretical gold standard, used in optimizations like Thomas' Write Rule |
The relationship between these schedule classes is a strict subset hierarchy:
Conflict Serializable Schedules⊂View Serializable Schedules⊂All Serializable SchedulesEvery conflict-serializable schedule is automatically view serializable, but a view-serializable schedule with blind writes is not necessarily conflict serializable.
Consider the following classic schedule S with transactions T1, T2, and T3 operating on data item Q:
| Step | T1 | T2 | T3 |
|---|---|---|---|
| 1 | read(Q) | ||
| 2 | write(Q) | ||
| 3 | write(Q) | ||
| 4 | write(Q) |
Let us analyze the conflicting pairs on item Q:
We have edges T1→T2 and T2→T1. This forms a directed cycle:
T1⟷T2Because the precedence graph contains a cycle, schedule S is not conflict serializable.
Let us test the three view equivalence conditions:
All three view conditions are satisfied. Therefore, schedule S is view serializable, equivalent to the serial schedule ⟨T1,T2,T3⟩.
Notice that T2 and T3 executed blind writes. Step 2 wrote to Q without reading it, and was immediately overwritten by Step 3.
Appeared: 2020 Q.6(b) — (06 marks)
Question:
What is view serializability? Why do we need view serializability? Check the view serializability of the following schedule if any.
| T1 | T2 |
|---|---|
| R(X) | |
| W(X) | |
| R(X) | |
| W(X) | |
| R(Y) | |
| W(Y) | |
| R(Y) | |
| W(Y) |
Full Answer:
A schedule S is view serializable if it is view equivalent to some serial schedule S′. Two schedules S and S′ over the same transactions are view equivalent if they satisfy three conditions for every data item Q:
We need view serializability for three primary reasons:
Let the given schedule be S. We index the operations chronologically:
| Step | T1 | T2 | Description |
|---|---|---|---|
| 1 | read(X) | T1 reads initial X | |
| 2 | write(X) | T1 updates X | |
| 3 | read(X) | T2 reads X produced by T1 | |
| 4 | write(X) | T2 performs final write on X | |
| 5 | read(Y) | T1 reads initial Y | |
| 6 | write(Y) | T1 updates Y | |
| 7 | read(Y) | T2 reads Y produced by T1 | |
| 8 | write(Y) | T2 performs final write on Y |
We test if S is view equivalent to the serial schedule S′=⟨T1,T2⟩:
Initial read condition:
Read-from (updated read) condition:
Final write condition:
All three conditions are satisfied with respect to the serial schedule ⟨T1,T2⟩.
Figure 1: Precedence graph for 2020 Q.6(b) confirming acyclic conflict serialization order T1→T2.
Also, every conflicting instruction pair on both X and Y runs in T1 before T2:
Because all edges point from T1 to T2, the precedence graph is acyclic, and remember that every conflict-serializable schedule is automatically view serializable.
Conclusion: The schedule is view serializable (as well as conflict serializable), with equivalent serial execution order:
⟨T1,T2⟩Source: Silberschatz 7e · Chapter 17 (Practice Exercise 17.8)
Exam Relevance: High-Probability Advanced Exam Question
Key Tested Concept: The 3 formal conditions of View Equivalence, blind writes, and why View Serializability is strictly weaker than Conflict Serializability.
Problem Statement:
- State the three formal conditions required for two schedules S and S′ to be view equivalent.
- Present an interleaved schedule containing blind writes that is view serializable but NOT conflict serializable.
- Prove why the schedule is view serializable to a serial schedule and draw its cyclic precedence graph.
Model Exam-Style Solution:
Three Formal Conditions of View Equivalence: Two schedules S and S′ on the same set of transactions are view equivalent if:
The Classic Schedule with Blind Writes: Consider schedule S with transactions T1,T2,T3:
S:r1(A);w2(A);w1(A);w3(A)(Notice that w2(A) and w3(A) are blind writes—writes executed without reading A first).
Proof of Non-Conflict Serializability:
Proof of View Serializability to Serial Schedule ⟨T1,T2,T3⟩: Let S′=⟨T1,T2,T3⟩:
💡 RUET Exam Takeaway: Every conflict serializable schedule is view serializable, but the converse is not true. A schedule can be view serializable without being conflict serializable only if it contains blind writes!
← Previous: T10.4: Building Serializable and Non-Serializable Schedules | 🏠 Index | Next: T10.6: Recoverable, Cascadeless, and Strict Schedules →