Silberschatz Chapter 17 exercises form the primary source for RUET semester-final questions on serializability:
Textbook Exercise
RUET Past Exam Occurrence
Printed Marks
Exam Sub-Question & Description
Exercise 17.14
2018 · Q.6(a)
3m / 4m
Distinguish between a serial schedule and a serializable schedule.
Exercise 17.15
2017 · Q.5(c) 2019 · Q.4(a)
6m 7m
Transactions T1,T2 with conditional updates (if A = 0 then B := B+1;). Prove consistency preservation of serial runs, show nonserializable concurrent interleaving, and analyze serializable concurrent execution.
T10.1 · Foundations of Concurrency, Serial Schedules & Isolation Levels
Exercise 17.14 · Distinction Between Serial and Serializable Schedules
Question (Silberschatz 7e Exercise 17.14).
Explain the distinction between the terms serial schedule and serializable schedule.
1. Core Principles & Concept Overview
Schedule (S): A chronological sequence of instructions that specifies the execution order of operations across a set of concurrent transactions {T1,T2,…,Tn}. It must preserve the internal program order of each individual transaction.
Serial Schedule: A non-interleaved schedule where transactions run strictly one after another from start to finish. If transaction Ti begins execution, no operation of any other transaction Tj (j=i) can execute until Ti has committed or aborted.
Serializable Schedule: An interleaved (concurrent) schedule whose computational effect on the database state (and transaction outputs) is provably identical to that of some serial schedule involving the same transactions.
2. Detailed Step-by-Step Solution
Step 1: Formal Mathematical Definitions
Let T={T1,T2,…,Tn} be a set of transactions.
Serial Schedule Definition:
A schedule S on T is serial if for every pair of transactions Ti,Tj∈T (i=j), all operations of Ti precede all operations of Tj, or all operations of Tj precede all operations of Ti. Formally:
Serializable Schedule Definition:
A schedule S on T is serializable if there exists a serial schedule Sserial over T such that for every consistent initial database state D0:
Serial Schedule S1=⟨T1,T2⟩: T1 completes entirely (A→900), then T2 completes entirely (A→900×1.10=990).
Interleaved Non-Serializable Schedule Sbad (Lost Update): T1 reads A=1000; T2 reads A=1000; T1 writes A=900; T2 writes A=1100. Final A=1100 (Update of T1 lost; neither serial order produces 1100).
Interleaved Serializable Schedule Sgood:
If T1 and T2 operate on disjoint data items (e.g., T1 operates on A while T2 operates on B), their operations can be completely interleaved concurrently. The final database state is strictly identical to running T1 then T2 or T2 then T1.
3. RUET Exam Insights & Examiner Notes
Exam Paper Reference: In RUET 2018 Q.6(a), this was asked for 3 marks following a 1-mark definition of a transaction and schedule.
Examiner Expectations:
Define both terms clearly using the keyword interleaving (0.5 + 0.5 marks).
State the equivalence requirement (must produce the same result as some serial schedule) (1.0 mark).
Draw a comparative table highlighting resource utilization, throughput, and scheduling overhead (1.0 mark).
Exercise 17.18 · Rationale for Concurrent Transaction Execution
Question (Silberschatz 7e Exercise 17.18).
Why do database systems support concurrent execution of transactions, despite the extra effort needed to ensure that concurrent execution does not cause any problems?
1. Core Principles & Concept Overview
Executing transactions concurrently introduces significant software complexity: locking managers, latch contention, deadlock detection, undo/redo log maintenance, and abort cascades. Despite this immense overhead, serial execution is unacceptable in modern commercial DBMS architectures due to physical hardware characteristics and user response-time requirements.
2. Detailed Step-by-Step Solution
Database systems implement concurrent execution for two fundamental engineering reasons:
1. Improved Throughput and Resource Utilization
A database transaction alternates between CPU processing (e.g., evaluating WHERE predicates, computing arithmetic formulas, hashing keys in memory) and Disk/Storage I/O (e.g., reading data blocks from non-volatile SSDs/HDDs, writing WAL buffers).
The Serial Bottleneck: If transactions run serially, when transaction T1 issues a disk read (taking 1–10 ms), the CPU remains completely idle. Conversely, when T1 executes CPU-bound aggregation in memory, disk controllers and I/O channels sit idle.
Concurrent Overlap: By executing transactions concurrently, the DBMS achieves CPU-I/O overlap. While transaction T1 waits for a page fault or disk I/O transfer, the CPU immediately switches context to execute instructions for transaction T2 or T3.
Mathematical Impact on Throughput:
If transaction processing time consists of compute time C and I/O wait time I/O, serial throughput is bounded by:
Throughputserial=C+I/O1
Under ideal concurrent execution with k balanced transactions:
Throughputconcurrent≈min(Ck,I/Ok)≫Throughputserial
2. Reduced Average Waiting Time and Predictable Latency
In any real-world database workload, transaction durations vary across orders of magnitude:
Short Transactions: Point lookups, balance checks, single-row updates (e.g., duration ≈1 ms).
The Convoy Phenomenon under Serial Execution: If a 5-minute batch report begins executing serially, a 1-millisecond ATM balance inquiry arriving one millisecond later must wait the full 5 minutes before it can run. This leads to unacceptable response times and high variance in transaction latency.
Concurrent Interleaving: Concurrency control schedulers allow short transactions to interleave with long-running transactions. The short transaction accesses its data items, executes, and commits within milliseconds while the long-running transaction is reading other pages, reducing the average turnaround time across all transactions.
3. RUET Exam Insights & Examiner Notes
Key Technical Terms: Always structure your answer under two clear headings: (1) Resource Utilization & Hardware Overlap (CPU/Disk I/O) and (2) Reduced Average Response Time (Preventing Short Transaction Starvation / Convoy Effect).
Mark Calibration: Typically evaluated as a 3-mark or 4-mark question. Citing the CPU-I/O overlap diagram from Lecture Deck 07 Slide 3 guarantees full marks.
Exercise 17.11 · Multiprocessor Systems and Partial Operation Ordering
Question (Silberschatz 7e Practice Exercise 17.11).
The definition of a schedule assumes that operations can be totally ordered by time. Consider a database system that runs on a system with multiple processors, where it is not always possible to establish an exact ordering between operations that executed on different processors. However, operations on a data item can be totally ordered.
Does this situation cause any problem for the definition of conflict serializability? Explain your answer.
1. Core Principles & Concept Overview
Total Order vs. Partial Order: A total order <S over a schedule requires that for any two distinct operations o1,o2∈S, either o1<So2 or o2<So1. In distributed or symmetric multiprocessing (SMP) systems with weak memory models or unsynchronized physical clocks, establishing a global wall-clock total order between operations running on different CPUs is physically impossible.
Conflicting Operations: Two operations Ii∈Ti and Ij∈Tj (i=j) conflict if and only if:
They access the exact same data itemQ.
At least one of the operations is a write (write(Q)).
2. Detailed Step-by-Step Solution
Step 1: The Basis of Conflict Serializability
The fundamental theorem of conflict serializability states that a schedule S is conflict serializable if and only if its precedence graphG=(V,E) is acyclic.
Let us inspect how directed edges in the precedence graph are created:
A directed edge Ti→Tj is added to E if and only if an operation oi∈Ti conflicts with an operation oj∈Tj, and oi executes before oj.
Step 2: Analysis of the Given Multiprocessor Condition
The problem specifies two premises:
Operations on different data items on different processors cannot be totally ordered (they are partially ordered).
Operations on the same data itemQcan be totally ordered (enforced by hardware memory-bus locks, cache coherence protocols like MESI, or DBMS data-item latches).
Step 3: Formal Deduction
Conflict Evaluation Requires Same Data Item: By definition, two operations can conflict only if they access the same data item Q.
Order of Conflicting Operations is Well-Defined: Because all operations on any given data item Q are totally ordered by the physical memory controller or latch manager, for any two conflicting operations oi(Q) and oj(Q), the system unambiguously determines whether oi(Q) occurred before oj(Q) or vice versa.
Non-Conflicting Operations Commute Freely: If transaction T1 on Processor 1 writes data item A, and transaction T2 on Processor 2 writes data item B, these operations do not access the same item. They do not conflict. Swapping their execution order in any hypothetical global schedule does not change:
The value read by any subsequent operation.
The final state of either data item A or B.
Any directed edge in the precedence graph.
Conclusion: Because all conflicting pairs are totally ordered, every directed edge in the precedence graph G is uniquely and unambiguously established. The presence or absence of directed cycles in G remains strictly deterministic.
Final Answer: No, this situation causes no problem whatsoever for the definition of conflict serializability. Conflict serializability depends exclusively on the relative order of conflicting operations. Since operations on any individual data item are totally ordered, all conflicting dependencies are well-defined, and non-conflicting operations can execute in arbitrary partial order without affecting serializability.
3. RUET Exam Insights & Examiner Notes
Examiner's Checklist: State clearly that conflicting operations by definition operate on the same data item. Mention that hardware cache-coherence / latch mechanisms order same-item accesses, while disjoint-item operations are commutative.
Exercise 17.16 · Commit Ordering versus Serialization Ordering
Question (Silberschatz 7e Exercise 17.16).
Give an example of a serializable schedule with two transactions such that the order in which the transactions commit is different from the serialization order.
1. Core Principles & Concept Overview
Serialization Order: The order of transactions in the equivalent serial schedule, determined by the topological sort of the directed edges in the precedence graph G=(V,E). If there is an edge T1→T2, then T1 must precede T2 in serialization order.
Commit Order: The physical sequence in time in which transactions issue their commit instruction (ci) and have their commit log records flushed to stable storage.
Independence: A concurrency control protocol may serialize T1 before T2 due to an early read-write conflict, yet T1 may remain active performing other unrelated tasks or slow computations while T2 finishes quickly and commits.
2. Detailed Step-by-Step Solution
Step 1: Constructing the Schedule
Consider two transactions T1 and T2 operating on data items A and B:
T1: Writes to item A, performs a lengthy internal computation, then commits.
T2: Reads item A, writes item B, and immediately commits.
We define the concurrent schedule Sc as follows:
Step
Time
Transaction T1
Transaction T2
Description
1
t1
write(A)
T1 writes to item A
2
t2
read(A)
T2 reads item A (conflicts with step 1: w1(A)<r2(A))
3
t3
write(B)
T2 writes to item B
4
t4
commit (c2)
T2 commits first
5
t5
write(C)
T1 performs subsequent work
6
t6
commit (c1)
T1 commits second
flowchart LR
subgraph SerializationOrder ["Serialization Order (T1 -> T2)"]
T1["T1: w1(A)"] -->|Conflict on A| T2["T2: r2(A)"]
end
subgraph CommitOrder ["Physical Commit Order (c2 < c1)"]
C2["Commit T2 (t4)"] --> C1["Commit T1 (t6)"]
end
Step 2: Verification of Conflict Serializability and Serialization Order
Identify Conflicting Instructions:
Step 1 (T1:write(A)) conflicts with Step 2 (T2:read(A)). Since Step 1 precedes Step 2, this forces the directed edge:
T1⟶T2
There are no other conflicting pairs between T1 and T2 on items B or C.
Precedence Graph Evaluation:
Precedence graph G has vertices V={T1,T2} and directed edges E={(T1,T2)}.
The graph is strictly acyclic. Therefore, schedule Sc is conflict serializable.
Serialization Order:
The unique topological sort of G is ⟨T1,T2⟩. Thus:
Serialization Order=⟨T1,T2⟩
Step 3: Comparison with Commit Order
Transaction T2 commits at time t4.
Transaction T1 commits at time t6 (t4<t6).
Therefore:
Commit Order=⟨T2,T1⟩
The serialization order ⟨T1,T2⟩ is the exact reverse of the physical commit order ⟨T2,T1⟩.
3. RUET Exam Insights & Examiner Notes
Model Answer Strategy: Use the r1(A)<w2(A) pattern (read-write anti-dependency) to demonstrate both conflict serializability and recoverability simultaneously. Examiners assign full marks when students explicitly write out the precedence graph edge and commit timestamps.
Practice Exercise 17.6 · Precedence Graph Conflict Serializability Test (Figure 17.16)
Question (Silberschatz 7e Practice Exercise 17.6).
Consider the precedence graph of Figure 17.16. Is the corresponding schedule conflict serializable? Explain your answer.
Figure 17.16 — Precedence graph for Practice Exercise 17.6.
1. Core Principles & Concept Overview
Precedence Graph (Serialization Graph): A directed graph G=(V,E) constructed from a schedule S:
Vertices V: The set of all committed transactions participating in schedule S.
Directed Edges E: An edge Ti→Tj exists if and only if an operation of Ti executed before and conflicted with an operation of Tj.
The Conflict Serializability Theorem:
A schedule S is conflict serializable if and only if its precedence graph G contains no directed cycles (i.e., G is a Directed Acyclic Graph, or DAG).
Topological Sort: A linear ordering of vertices in a DAG such that for every directed edge u→v, vertex u comes before v in the ordering. Every topological sort corresponds to an equivalent serial schedule.
2. Detailed Step-by-Step Solution
Step 1: Formal Graph Extraction from Figure 17.16
By rigorous topological examination of the nodes and directed arrowheads in Figure 17.16:
Stating "Yes, it is conflict serializable" with the acyclic precedence graph theorem: 1 Mark.
Listing the complete set of directed edges and verifying absence of cycles: 2 Marks.
Deriving the equivalent serial schedule(s) via topological sorting: 2 to 3 Marks.
Crucial Tip: RUET questions like 2023 Q.8(b) explicitly ask to "find all possible serialized schedules". Always check if multiple nodes achieve in-degree 0 simultaneously to enumerate all valid topological permutations.
Exercise 17.15 · Conditional Increment Schedule and Consistency Invariants
Question (Silberschatz 7e Exercise 17.15).
Consider the following two transactions:
T13:read(A);T13:read(B);T13:if A=0 then B:=B+1;T13:write(B).T14:read(B);T14:read(A);T14:if B=0 then A:=A+1;T14:write(A).
Let the consistency requirement be A=0∨B=0, with A=B=0 as the initial values.
a. Show that every serial execution involving these two transactions preserves the consistency of the database.
b. Show a concurrent execution of T13 and T14 that produces a nonserializable schedule.
c. Is there a concurrent execution of T13 and T14 that produces a serializable schedule?
1. Core Principles & Concept Overview
Database Consistency Invariant (I): A predicate defined on database states. Here, I≡(A=0∨B=0). The database is consistent if at least one of the variables equals 0; it becomes inconsistent if and only if both A=0 and B=0.
Serial Correctness: By the definition of transaction consistency, if individual transactions are correct, any serial execution starting from a consistent state must terminate in a consistent state.
Interleaving Vulnerability: In concurrent execution, transactions can read obsolete states before pending writes are flushed, leading to logical invariant breakdown.
2. Detailed Step-by-Step Solution
Part (a): Consistency Preservation in Every Serial Execution
For two transactions T13 and T14, there are exactly 2!=2 possible serial executions:
Case 1: Serial Schedule S1=⟨T13,T14⟩
Initial database state: A=0,B=0.
Execution of T13:
Reads A=0 and B=0.
Evaluates condition: A=0⟹(0=0) is True.
Executes branch: B:=B+1=0+1=1.
Writes B=1.
Intermediate state: A=0,B=1.
Execution of T14:
Reads B=1 and A=0.
Evaluates condition: B=0⟹(1=0) is False.
Skips increment of A. Local value remains A=0.
Writes A=0.
Final State of S1:A=0,B=1.
Invariant Check:(A=0∨B=0)⟹(0=0∨1=0)≡True∨False≡True
Consistency is preserved!
Case 2: Serial Schedule S2=⟨T14,T13⟩
Initial database state: A=0,B=0.
Execution of T14:
Reads B=0 and A=0.
Evaluates condition: B=0⟹(0=0) is True.
Executes branch: A:=A+1=0+1=1.
Writes A=1.
Intermediate state: A=1,B=0.
Execution of T13:
Reads A=1 and B=0.
Evaluates condition: A=0⟹(1=0) is False.
Skips increment of B. Local value remains B=0.
Writes B=0.
Final State of S2:A=1,B=0.
Invariant Check:(A=0∨B=0)⟹(1=0∨0=0)≡False∨True≡True
Consistency is preserved!
Conclusion for (a): In both serial orders, consistency condition A=0∨B=0 holds. ■
Part (b): Concurrent Execution Producing a Nonserializable Schedule
To construct a nonserializable execution, interleave the operations such that both transactions read the initial values of 0 before either transaction performs its write:
Step
Time
Transaction T13
Transaction T14
Local Variables / State
1
t1
read(A);
T13 reads A=0
2
t2
read(B);
T13 reads B=0
3
t3
read(B);
T14 reads B=0
4
t4
read(A);
T14 reads A=0
5
t5
if A=0 then B:=B+1; write(B);
T13 evaluates 0=0 (True); sets B=1; writes B=1
6
t6
if B=0 then A:=A+1; write(A);
T14 evaluates 0=0 (True); sets A=1; writes A=1
Invariant Evaluation
Final Database State:A=1,B=1.
Consistency Predicate:(A=0∨B=0)⟹(1=0∨1=0)≡False∨False≡False
The database is in an inconsistent state!
Formal Proof of Nonserializability
Conflict Analysis:
T13 reads item A at step 1 before T14 writes item A at step 6:
r13(A)<Sw14(A)⟹T13⟶T14
T14 reads item B at step 3 before T13 writes item B at step 5:
r14(B)<Sw13(B)⟹T14⟶T13
Precedence Graph:
The precedence graph contains a directed cycle:
T13⟷T14
Since the precedence graph contains a directed cycle and the schedule terminates in an inconsistent state (A=1,B=1) that no serial schedule can ever generate, the schedule is strictly nonserializable. ■
Part (c): Can a Concurrent Execution Produce a Serializable Schedule?
Answer: Yes. A concurrent (interleaved) execution can produce a serializable schedule, provided the interleaving preserves an acyclic conflict dependency structure.
Concrete Example of a Serializable Concurrent Execution
Consider the following interleaved schedule where T13 executes its read and write on B before T14 reads B, but T14 begins reading A early:
Step
Transaction T13
Transaction T14
Evaluation & Database State
1
read(A);
T13 reads A=0
2
read(B);
T13 reads B=0
3
if A=0 then B:=B+1;
T13 computes B:=1
4
write(B);
T13 writes B=1 to database
5
read(B);
T14 reads updated B=1
6
read(A);
T14 reads A=0
7
if B=0 then A:=A+1;
T14 evaluates 1=0 (False); A remains 0
8
write(A);
T14 writes A=0
Conflict and Serializability Verification
Conflict Analysis:
On item B: T13 writes B (step 4) before T14 reads B (step 5) ⟹T13→T14.
On item A: T13 reads A (step 1) before T14 writes A (step 8) ⟹T13→T14.
Precedence Graph: Contains only one directed edge T13→T14. It is strictly acyclic.
Equivalence: The schedule is conflict-equivalent to the serial schedule ⟨T13,T14⟩.
Final State:A=0,B=1, which satisfies A=0∨B=0 (True).
3. RUET Exam Insights & Examiner Notes
Exam Paper Link: RUET 2017 Q.5(c) (6 marks) and 2019 Q.4(a) (7 marks) are direct copies of this textbook exercise.
Examiner Traps:
In 2019 Q.4(a), the question replaced A,B with P,Q and changed initial values to P=Q=5 and condition to P=10. In that exam paper, students who solved it symbolically as in Exercise 17.15 scored full marks.
When drawing the nonserializable schedule, explicitly display the cycle T1→T2 and T2→T1 along with the inconsistent state (A=1,B=1).
Practice Exercise 17.8 · The Lost Update Anomaly Across SQL Isolation Levels
Question (Silberschatz 7e Practice Exercise 17.8).
The lost update anomaly is said to occur if a transaction Tj reads a data item, then another transaction Tk writes the data item (possibly based on a previous read), after which Tj writes the data item. The update performed by Tk has been lost, since the update done by Tj ignored the value written by Tk.
a. Give an example of a schedule showing the lost update anomaly.
b. Give an example schedule to show that the lost update anomaly is possible with the read committed isolation level.
c. Explain why the lost update anomaly is not possible with the repeatable read isolation level.
1. Core Principles & Concept Overview
Lost Update Anomaly: Occurs when two transactions concurrently read the same initial state of a data item Q and subsequently compute updates based on that value. The transaction that writes last overwrites the intermediate update of the other transaction without incorporating it.
Locking Mechanics Across Isolation Levels:
Read Committed: Requires short-duration shared (read) locks (acquired before read, released immediately after read) and long-duration exclusive (write) locks (held until commit).
Repeatable Read: Requires long-duration shared locks (held until commit) and long-duration exclusive locks (held until commit).
2. Detailed Step-by-Step Solution
Part (a): Example Schedule of the Lost Update Anomaly
Let A represent a bank account with initial balance A=100.
T1: Deposit $50 (A:=A+50).
T2: Deposit $100 (A:=A+100).
Correct serial outcome (⟨T1,T2⟩ or ⟨T2,T1⟩): A=100+50+100=250.
Interleaved Schedule Demonstrating Lost Update:
Step
Time
Transaction T1
Transaction T2
Balance A in DB
Description
1
t1
read(A)
100
T1 reads local A1=100
2
t2
read(A)
100
T2 reads local A2=100
3
t3
A1:=A1+50
100
T1 computes 150 locally
4
t4
write(A) (150)
150
T1 writes 150 to DB
5
t5
commit
150
T1 commits
6
t6
A2:=A2+100
150
T2 computes 100+100=200
7
t7
write(A) (200)
200
T2 writes 200, overwriting T1's update!
8
t8
commit
200
T2 commits
Result: Final balance A=200. The $50 deposit made by T1 has been completely lost.
Part (b): Lost Update Under the Read Committed Isolation Level
Under Read Committed implemented via lock-based protocols:
Shared locks (S-lock) are short-duration: acquired before reading and released immediately after reading.
Exclusive locks (X-lock) are long-duration: acquired before writing and held until transaction commit.
T2 obtains X-lock, writes 200 based on stale read of 100, commits.
Analysis: Because T1 and T2 both released their read locks at steps 1 and 2, neither transaction blocked the other's subsequent write. Thus, Read Committed permits the lost update anomaly.
Part (c): Why Lost Update Is Impossible Under Repeatable Read
Under Repeatable Read implemented via locking:
Long-duration shared locks: When a transaction reads data item A, it acquires an S-lock(A) and holds it until the transaction terminates (commit or abort).
Lock Compatibility: An exclusive lock (X-lock) is incompatible with a shared lock (S-lock):
Compatible(S,X)=False
Impossibility Proof by Contradiction:
Suppose a lost update occurs under Repeatable Read. Then T1 and T2 both read item A before either writes A.
When T1 reads A, it acquires S-lock1(A) and holds it until T1 commits.
When T2 reads A, it acquires S-lock2(A) (allowed, since S-locks are mutually compatible) and holds it until T2 commits.
Now consider what happens when T1 attempts to write A:
T1 must upgrade its lock to X-lock1(A).
However, T2 still holds S-lock2(A). Because X and S conflict, T1 is forced into a wait state.
Next, when T2 attempts to write A:
T2 must upgrade its lock to X-lock2(A).
However, T1 still holds S-lock1(A). T2 is also forced into a wait state.
Both transactions are waiting for each other to release their shared locks. This produces an immediate deadlock:
T1waits forT2waits forT1
The deadlock detector detects the cycle and aborts one of the transactions (e.g., T2).
If T2 aborts, its stale write never occurs, and T1 commits successfully (A=150). If T2 is re-executed, it reads the updated A=150 and computes 150+100=250.
In no execution can both transactions write without one aborting or blocking until the other finishes.
Conclusion: The lost update anomaly is mathematically impossible under Repeatable Read. ■
3. RUET Exam Insights & Examiner Notes
Exam Answer Structure: Draw the lock compatibility matrix and explicitly trace the lock upgrade deadlock for part (c). RUET examiners look specifically for the phrase "lock upgrade conflict produces a deadlock, forcing one transaction to abort or wait".
Exercise 17.20 · Non-Serializable Schedules Under SQL Isolation Levels
Question (Silberschatz 7e Exercise 17.20).
For each of the following isolation levels, give an example of a schedule that respects the specified level of isolation but is not serializable:
a. Read uncommitted
b. Read committed
c. Repeatable read
1. Core Principles & Concept Overview
ANSI SQL-92 defines four isolation levels characterized by the prohibition of specific concurrency phenomena:
Isolation Level
Dirty Read (P1)
Non-Repeatable Read (P2)
Phantom Read (P3)
Conflict Serializable
Read Uncommitted
Allowed
Allowed
Allowed
No
Read Committed
Prevented
Allowed
Allowed
No
Repeatable Read
Prevented
Prevented
Allowed
No
Serializable
Prevented
Prevented
Prevented
Yes
2. Detailed Step-by-Step Solution
Part (a): Read Uncommitted (Exhibiting Dirty Read)
Requirement: Must respect Read Uncommitted (which permits dirty reads) while being nonserializable.
Mechanism: Transaction T2 reads a data item modified by an uncommitted transaction T1, after which T1 updates another item or aborts.
Schedule Sa:
Step
Transaction T1
Transaction T2
Database State
1
write(A,500)
A=500 (uncommitted)
2
read(A) (500)
Local A2=500 (Dirty Read)
3
write(B,500)
B=500
4
commit
T2 commits
5
read(B) (500)
T1 reads B=500
6
commit
T1 commits
Conflict Analysis:
w1(A) precedes r2(A)⟹T1→T2.
w2(B) precedes r1(B)⟹T2→T1.
Precedence Graph: Cycle T1⟷T2.
Verdict: Respects Read Uncommitted, but is nonserializable.
Part (b): Read Committed (Exhibiting Non-Repeatable Read)
Requirement: Must forbid dirty reads (every read must see committed data), but permit non-repeatable reads.
Mechanism:T1 reads A; T2 updates A and commits; T1 reads A again and observes a different value.
Schedule Sb:
Step
Transaction T1
Transaction T2
Description
1
read(A) (100)
T1 reads committed initial A=100
2
read(B) (50)
T2 reads committed initial B=50
3
write(A,200)
T2 modifies A
4
commit
T2 commits
5
read(A) (200)
T1 reads A again (sees 200, unrepeatable read!)
6
write(B,300)
T1 writes B=300
7
commit
T1 commits
Verification of Read Committed: Every read operation in Sb (step 1, step 2, step 5) reads strictly committed data. No dirty reads occur.
Invariant Breakdown: Final database state has A=−50,B=−50⟹A+B=−100<0 (Inconsistent).
Verdict: Respects Repeatable Read, but is nonserializable.
3. RUET Exam Insights & Examiner Notes
Examiner's Preference: For Repeatable Read, providing the Write Skew schedule demonstrates superior academic depth compared to standard phantom reads because it relies strictly on primitive read/write operations without requiring complex relational table definitions.
Exercise 17.21 · Phantom Phenomenon and Predicate Reads
Question (Silberschatz 7e Exercise 17.21).
Suppose that in addition to the operations read and write, we allow an operation pred_read(r,P), which reads all tuples in relation r that satisfy predicate P.
a. Give an example of a schedule using the pred_read operation that exhibits the phantom phenomenon and is nonserializable as a result.
b. Give an example of a schedule where one transaction uses the pred_read operation on relation r and another concurrent transaction deletes a tuple from r, but the schedule does not exhibit a phantom conflict. (To do so, you have to give the schema of relation r and show the attribute values of the deleted tuple.)
1. Core Principles & Concept Overview
Predicate Read (pred_read(r,P)): A query operation that searches relation r and returns the subset of tuples {t∈r∣P(t)=True}.
The Phantom Phenomenon: Occurs when a transaction T1 executes a predicate read, and a concurrent transaction T2 inserts, deletes, or updates a tuple satisfying predicate P and commits. If T1 re-executes the predicate read, it discovers a different set of tuples (a "phantom" has appeared or vanished), violating isolation even if all individual tuple-level locks were held.
Conflict Condition for Predicate Reads: An operation insert(t) or delete(t) on relation r conflicts with pred_read(r,P)if and only if the tuple t satisfies predicate P (P(t)=True). If P(t)=False, the operations are mutually non-conflicting.
2. Detailed Step-by-Step Solution
Part (a): Schedule Exhibiting the Phantom Phenomenon
Let relation r be account(account_number, branch_name, balance).
Predicate P:branch_name=’Perryridge’.
T1: Audits Perryridge accounts. Computes total balance by executing pred_read, computes average, then re-reads to verify.
T2: Opens a new account at Perryridge branch (tnew=(’A-301’,’Perryridge’,500)) and updates bank total.
Practice Exercise 17.5 · Conflict Serializability versus View Serializability
Question (Silberschatz 7e Practice Exercise 17.5).
Since every conflict-serializable schedule is view serializable, why do we emphasize conflict serializability rather than view serializability?
1. Core Principles & Concept Overview
Hierarchy of Schedules:Serial⊂Conflict-Serializable⊂View-Serializable⊂All Concurrent Schedules
Every conflict-serializable schedule is view-serializable. View serializability is a strictly weaker (more permissive) constraint that correctly classifies schedules containing blind writes (writing a data item without reading it first) as serializable.
2. Detailed Step-by-Step Solution
Database systems emphasize conflict serializability rather than view serializability for three decisive theoretical and practical reasons:
1. Computational Complexity (P vs. NP-Complete)
Testing Conflict Serializability is in P (Polynomial Time):
To test if an arbitrary schedule S with n transactions and m operations is conflict serializable, we construct its precedence graph G=(V,E) and run cycle detection (e.g., Kahn's algorithm or Depth-First Search). The time complexity is:
O(∣V∣+∣E∣)=O(n+m2)
This can be computed almost instantaneously by a database engine.
Testing View Serializability is NP-Complete:
Deciding whether an arbitrary schedule S is view serializable was proven by Papadimitriou (1979) to be NP-complete. As the number of transactions n grows, testing view serializability requires testing polygraph acyclicity or checking against all n! possible serial permutations in the worst case:
Worst-Case Complexity=O(n!⋅m)
A database engine cannot afford an exponential-time algorithm to validate schedules.
2. On-the-Fly Protocol Enforceability
A database scheduler does not inspect a complete schedule after it finishes; it must process instructions dynamically in real time as they arrive from client connections.
There is no known practical, efficient, real-time concurrency control protocol (such as locking or timestamping) that can dynamically accept all view-serializable schedules while rejecting nonserializable ones.
Protocols that allow non-conflict-serializable view-serializable schedules (such as Thomas' Write Rule) rely on specialized domain properties (blind writes) rather than general view equivalence.
3. Practical Safety Margin
The set of view-serializable schedules that are not conflict-serializable is relatively small and consists almost entirely of schedules with artificial blind writes (w(Q) without prior r(Q)).
In real-world transaction workloads, transactions almost always read a record before modifying it (e.g., check account balance, verify inventory count, retrieve foreign key). When transactions contain no blind writes:
No Blind Writes⟹View Serializability≡Conflict Serializability
Hence, enforcing conflict serializability sacrifices virtually zero real-world concurrency while providing guaranteed polynomial-time verification.
Mention that view serializability differs from conflict serializability only in the presence of blind writes (1.0 mark).
Practice Exercise 17.9 · Snapshot Isolation and Write Skew in Banking Systems
Question (Silberschatz 7e Practice Exercise 17.9).
Consider a database for a bank where the database system uses snapshot isolation. Describe a particular scenario in which a nonserializable execution occurs that would present a problem for the bank.
1. Core Principles & Concept Overview
Snapshot Isolation (SI): A multi-version concurrency control (MVCC) protocol widely implemented in commercial DBMSs (PostgreSQL, Oracle, SQL Server):
Each transaction Ti reads from a private consistent snapshot of the database established at the timestamp Ti began. Reads never wait for writes, and writes never wait for reads!
First-Committer-Wins (FCW) Rule: When transaction Ti attempts to commit, the DBMS verifies whether another concurrent transaction Tj committed a write to any data item in Ti's write-set after Ti's start timestamp. If write-sets overlap (WriteSet(Ti)∩WriteSet(Tj)=∅), Ti aborts.
Write Skew Vulnerability: SI only detects concurrent writes to the exact same data item. If two concurrent transactions read overlapping data sets but write to disjoint data items, their write-sets do not intersect. Both commit under SI, potentially violating a global cross-item consistency constraint.
2. Detailed Step-by-Step Solution
Step 1: Define the Banking Database Schema and Invariant
Database Items: Two accounts owned by a single customer or business partners:
Account A (Checking balance): Initial A=100 ($100).
Account B (Savings balance): Initial B=100 ($100).
Bank Consistency Invariant (I): The bank offers an overdraft-protection feature where the combined balance must never fall below zero:
I≡(A+B≥0)
The customer may overdraw an individual account (allowing a negative balance) as long as the combined balance covers the deficit.
Step 2: Define Concurrent Transactions
Transaction T1: Customer withdraws $150 from Account A.
Logic: Checks if A+B≥150. If yes, deducts 150 from A (A:=A−150).
Transaction T2: Partner concurrently withdraws $150 from Account B.
Logic: Checks if A+B≥150. If yes, deducts 150 from B (B:=B−150).
Step 4: Analysis of Invariant Violation and Financial Loss
Why Snapshot Isolation Allowed Both:
Transaction T1's write-set is W1={A}.
Transaction T2's write-set is W2={B}.
Disjoint intersection: W1∩W2={A}∩{B}=∅.
The first-committer-wins rule triggers only if write-sets intersect. Since neither transaction wrote to the other's modified item, both transactions successfully commit!
Invariant Breakdown:
Final Database State: A=−50,B=−50.
Combined Balance: A + B = -50 + (-50) = -100 (-\100).
The bank constraint A+B≥0 is severely violated. The customer has extracted $300 from a $200 deposit, creating an unauthorized $100 uncollateralized overdraft!
Nonserializability Proof:
In any serial execution (⟨T1,T2⟩ or ⟨T2,T1⟩), the first transaction would deduct $150, leaving combined balance $50. The second transaction would then see combined balance $50, fail the condition A+B≥150, and abort.
Precedence graph edges: r1(B)<w2(B)⟹T1→T2, and r2(A)<w1(A)⟹T2→T1. Directed cycle T1⟷T2.
The schedule is nonserializable.
3. RUET Exam Insights & Examiner Notes
Examiner Keywords: Explicitly name this anomaly as Write Skew. Explain the First-Committer-Wins rule and show that disjoint write-sets (W1∩W2=∅) bypass SI conflict detection.
Practice Exercise 17.10 · Snapshot Isolation in Airline Reservation Systems
Question (Silberschatz 7e Practice Exercise 17.10).
Consider a database for an airline where the database system uses snapshot isolation. Describe a particular scenario in which a nonserializable execution occurs, but the airline may be willing to accept it in order to gain better overall performance.
1. Core Principles & Concept Overview
In high-throughput online transaction processing (OLTP) environments, strict serializability incurs steep costs: high lock contention, latency spikes, and aborted transactions. Commercial enterprises frequently trade absolute mathematical serializability for massive throughput gains if the resulting anomalies are manageable via business compensation (e.g., flight vouchers, automatic rebooking).
Step 2: Concurrent Booking Transactions Under Snapshot Isolation
Two passengers, Passenger 1 (T1) and Passenger 2 (T2), simultaneously book the last seat:
T1 and T2 both start at time t0 under Snapshot Isolation.
Both transactions read total_booked = 179 from their consistent snapshots.
Both check total_booked < 180⟹179<180 (True).
If seat allocation is handled across separate category counters (e.g., T1 books Economy Standard and updates std_booked, while T2 books Economy Flex and updates flex_booked), their write-sets are disjoint!
Both transactions commit successfully.
Final state: total_booked = 181 (The flight is overbooked by 1 passenger).
Step 3: Why the Airline Accepts This Nonserializable Execution
The airline willingly accepts this nonserializable overbooking outcome for three strategic business reasons:
Statistical No-Show Compensation:
In the commercial aviation industry, an average of 3% to 7% of ticketed passengers fail to show up at the departure gate (due to missed connecting flights, traffic delays, or cancellations). Airlines intentionally practice statistical overbooking. A minor overbooking anomaly caused by write skew is commercially advantageous because it ensures the flight departs at 100% capacity.
Elimination of Hot-Spot Lock Contention:
Under strict serializable locking (e.g., Strict 2PL), every passenger browsing or reserving a seat must acquire an exclusive lock on the central flight capacity record. During peak sales, thousands of users would queue on a single row lock, causing severe database connection pool exhaustion and website crashes. Under Snapshot Isolation, reads are non-blocking, latency drops from seconds to milliseconds, and throughput increases by orders of magnitude.
Cheap Business-Level Compensation:
If all 181 passengers actually arrive at the gate, the airline resolves the anomaly using standard operational compensation: offering a $300 travel voucher, a meal coupon, and an upgrade to the next available flight. The profit generated by running a non-blocking booking engine dwarfs the occasional cost of customer compensation vouchers.
3. RUET Exam Insights & Examiner Notes
Examiner's Perspective: This question evaluates your understanding of engineering trade-offs. Contrast ACID mathematical strictness with OLTP performance economics. Mention that non-blocking reads eliminate hot-spot row-lock bottlenecks.
Exercise 17.17 · Recoverable Schedules and Durability
Question (Silberschatz 7e Exercise 17.17).
What is a recoverable schedule? Why is recoverability of schedules desirable? Are there any circumstances under which it would be desirable to allow nonrecoverable schedules? Explain your answer.
1. Core Principles & Concept Overview
Recoverable Schedule: A schedule where, for every pair of transactions Ti and Tj such that Tj reads a data item previously written by Ti, the commit operation of Ti occurs before the commit operation of Tj.
The Durability Paradox: The ACID Durability property dictates that once a transaction commits, its effects cannot be erased or undone, even in the event of a system crash. If Tj commits after reading dirty data from Ti, and Ti subsequently aborts, the database cannot undo Tj without violating Durability, nor can it let Tj stand without violating Atomicity and Consistency.
2. Detailed Step-by-Step Solution
Step 1: Formal Mathematical Definition of Recoverability
A schedule S is recoverable if for all transactions Ti,Tj∈S:
If Tj reads an item Q written by Ti (i.e., wi(Q)<Srj(Q)),then ci<Scj
where ci and cj denote the commit operations of Ti and Tj respectively.
Step 2: Why Recoverability of Schedules Is Desirable
Consider what happens in a nonrecoverable scheduleSnonrec:
Step
Transaction T1
Transaction T2
Description
1
read(A)
T1 reads A
2
write(A,500)
T1 modifies A to 500
3
read(A) (500)
T2 reads uncommitted value written by T1
4
write(B,500)
T2 computes and writes B based on A=500
5
commit (c2)
T2 commits and returns success to user!
6
abort (a1)
T1 encounters a failure and aborts!
The Unresolvable Recovery Dilemma:
When T1 aborts at step 6, the DBMS must restore data item A to its pre-T1 state (Atomicity of T1).
However, transaction T2 already read A=500 and wrote B=500 based on that aborted value.
If the recovery manager attempts to rollback T2, it violates the Durability property of ACID (at step 5, the DBMS promised the user that T2 was committed and permanent).
If the recovery manager does not rollback T2, the database enters an inconsistent state containing values derived from aborted, non-existent operations.
Therefore, nonrecoverable schedules make true system recovery logically and physically impossible. Recoverability is mandatory to preserve the ACID guarantee.
Step 3: Are There Circumstances Where Nonrecoverable Schedules Are Desirable?
In general-purpose ACID transaction engines, nonrecoverable schedules are strictly forbidden. However, in highly specialized computing environments, they may be tolerated:
Non-Transactional Analytics & Scratchpads:
In massive parallel batch analytics (OLAP, ETL pipelines, or machine learning training loops), transactions do not represent banking records. If a worker fails, the entire batch job is discarded and re-run from the last global checkpoint. Allowing nonrecoverable reads avoids locking overhead.
Volatile In-Memory Telemetry / Logging:
In real-time sensor data collection, video streaming telemetry, or gaming metrics where data is transient, lost updates or dirty data reads are inconsequential compared to microsecond latency requirements.
Compensating Application-Level Workflows (Sagas):
In long-running microservice workflows where database-level locks cannot be held for hours, transactions commit eagerly. If an upstream service aborts, a compensating transaction (e.g., refund credit) is dispatched at the application layer rather than performing database engine rollback.
3. RUET Exam Insights & Examiner Notes
Exam Answer Checklist:
Write the formal definition: wi(Q)<Srj(Q)⟹ci<Scj (1 mark).
Draw the 6-step table showing T2 committing before T1 aborts (1.5 marks).
Explain the conflict between Atomicity and Durability (1.5 marks).
Practice Exercise 17.7 · Cascadeless Schedules and Cascading Rollbacks
Question (Silberschatz 7e Practice Exercise 17.7).
What is a cascadeless schedule? Why is cascadelessness of schedules desirable? Are there any circumstances under which it would be desirable to allow noncascadeless schedules? Explain your answer.
1. Core Principles & Concept Overview
Cascading Rollback (Cascading Abort): A phenomenon in a recoverable schedule where the failure and rollback of a single transaction T1 triggers a recursive, domino-effect rollback of multiple other dependent uncommitted transactions (T2,T3,…,Tk) that read data written by T1.
Cascadeless Schedule: A schedule that provably guarantees cascading aborts can never occur.
2. Detailed Step-by-Step Solution
Step 1: Formal Mathematical Definition of Cascadelessness
A schedule S is cascadeless (or avoids cascading aborts, ACA) if, for every pair of transactions Ti and Tj such that Tj reads a data item Q previously written by Ti, the commit operation of Ti appears before the read operation of Tj:
If wi(Q)<Srj(Q),then ci<Srj(Q)
Notice the critical distinction from recoverability:
Recoverable:ci<Scj (Tj can read early, but cannot commit until Ti commits).
Cascadeless:ci<Srj(Q) (Tj is strictly forbidden from even readingQ until Ti has committed).
In a schedule that is recoverable but not cascadeless, consider the following execution:
T1 writes A=500.
T2 reads A=500, writes B=250.
T3 reads B=250, writes C=125.
…
T100 reads from T99.
Now, transaction T1 suffers an arithmetic divide-by-zero error and aborts (a1).
The Cascade Disaster:
Because T1 aborted, its write to A never happened.
Therefore, T2's read of A is invalid ⟹T2 must be aborted.
Because T2 is aborted, T3's read of B is invalid ⟹T3 must be aborted.
The system is forced to abort all 100 transactions in a recursive domino cascade!
System Penalties:
Massive waste of CPU processing and disk I/O work performed by the 99 aborted transactions.
Sudden spike in transaction latency and log contention.
Risk of system freeze while the recovery manager reconstructs state.
Cascadelessness completely eliminates this vulnerability.
Step 3: Are There Circumstances Where Noncascadeless Schedules Are Desirable?
Yes. An architecture may allow noncascadeless schedules when:
Extremely Low Abort Rates: In workloads where transactions almost never abort (e.g., pre-validated transactions, read-only analytical queries, or no-abort hardware), the overhead of delaying reads until writers commit may degrade performance unnecessarily.
Read Latency Optimization: Waiting for a writing transaction to flush its commit record to disk (taking 2–10 ms) creates a noticeable read stall. Permitting eager reads of uncommitted dirty data enables immediate memory-speed pipelining between transactions, provided the system is prepared to handle the rare cascading abort.
3. RUET Exam Insights & Examiner Notes
Hierarchy Table Tip: Always include the recovery hierarchy inclusion:
Strict⊂Cascadeless⊂Recoverable
Mention that every cascadeless schedule is automatically recoverable, but not every recoverable schedule is cascadeless.
Question (Silberschatz 7e Exercise 17.19).
Explain why the read-committed isolation level ensures that schedules are cascade-free.
1. Core Principles & Concept Overview
Read-Committed Isolation: By definition, a transaction executing under the Read-Committed isolation level is strictly prohibited from observing any uncommitted data value written by another transaction (Dirty Read anomaly is barred).
Cascade-Free (Cascadeless) Schedule: A schedule where no transaction ever reads uncommitted data, ensuring that an abort of one transaction can never force the abort of another.
2. Detailed Step-by-Step Solution
Step 1: Definition Analysis
Definition of Cascadeless Schedule:
A schedule S is cascade-free (cascadeless) if and only if:
∀Ti,Tj∈S:(wi(Q)<Srj(Q))⟹(ci<Srj(Q))
That is, if transaction Tj reads a value of data item Q written by transaction Ti, then Ti must have committed prior to Tj's read operation.
Definition of Read-Committed Isolation Level:
Under Read-Committed isolation:
For any transaction Tj, any read operation rj(Q) is permitted to see only values written by transactions that have already committed.
If transaction Ti has written Q but has not yet committed, Tj cannot read that uncommitted version.
Step 2: Formal Deductive Proof
Assume for contradiction that a schedule S operates under the Read-Committed isolation level, but is not cascade-free.
If S is not cascade-free, there must exist at least one pair of transactions Ti and Tj such that:
Ti writes a data item Q (wi(Q)).
Tj reads data item Q (rj(Q)), observing the value produced by wi(Q).
Transaction Ti has not yet committed at the moment Tj performs rj(Q) (i.e., rj(Q)<Sci or Ti aborts).
However, the condition that Tj reads a value written by an uncommitted transaction Ti is the exact definition of a Dirty Read.
By the formal specification of the Read-Committed isolation level, dirty reads are strictly prohibited:
In a lock-based DBMS: Ti holds an exclusive lock (X-lock) on Q until Ti commits. Tj cannot acquire a shared lock (S-lock) to read Q and is blocked until Ti commits.
In an MVCC/snapshot DBMS: Tj's read is directed to the most recently committed version of Q prior to Tj's read timestamp, completely bypassing Ti's uncommitted version.
In both implementations, Tj is physically incapable of reading the uncommitted value written by Ti.
Because no transaction ever reads uncommitted data, an abort of Ti cannot affect Tj, because Tj never depended on Ti's aborted updates.
Therefore, cascading aborts are impossible, and every schedule under Read-Committed is guaranteed to be cascade-free. ■
3. RUET Exam Insights & Examiner Notes
Examiner's Grading Points:
State the exact definition of cascade-free (ci<rj(Q)) (1.5 marks).
Explain that Read-Committed forbids Dirty Reads via long-duration exclusive locks or MVCC committed-snapshot lookups (1.5 marks).
Conclude that since no uncommitted value is ever read, the prerequisite for a cascading rollback cannot exist (1.0 mark).
Complete Verification & Cross-Reference Index
Every exercise in this document is cross-referenced with syllabus taxonomy, past exam papers, and textbook sections: