Conflict Serializability
What Causes Conflicts?
Two operations conflict if:
-
They belong to different transactions
-
They access the same data item
-
At least one is a write operation
Conflict Cases:
-
read(A), read(A): No conflict (both just read)
-
read(A), write(A): Conflict! (order matters)
-
write(A), read(A): Conflict! (order matters)
-
write(A), write(A): Conflict! (final value depends on order)
Testing with Precedence Graph
Step 1: Draw the Graph
-
Each transaction = vertex
-
Add edge Ti → Tj if Ti's operation must come before Tj's operation
Step 2: Check for Cycles
-
No cycle: Schedule is conflict serializable ✓
-
Has cycle: Schedule is NOT conflict serializable ✗
Example: Good Schedule
T₁: read(A), write(A), read(B), write(B)
T₂: read(A), write(A), read(B), write(B)
Edge: T₁ → T₂ (T₁ writes A before T₂ reads A) Graph: T₁ → T₂ (no cycle) ✓
Example: Bad Schedule
T₁: read(A), write(A) read(B), write(B)
T₂: read(A), write(A), read(B)
Edges: T₁ → T₂ (A access) AND T₂ → T₁ (B access) Graph: T₁ ⟷ T₂ (cycle detected) ✗
View Serializability (Weaker Condition)
Two schedules are view equivalent if:
-
Same initial reads
-
Same intermediate reads (who reads what from whom)
-
Same final writes
Some schedules are view serializable but not conflict serializable.