What is serializability, and how do you check whether a schedule is conflict serializable?
HardConceptTransactions & ACID
Answer
A schedule is the order in which the operations of concurrent transactions are interleaved. A schedule is serializable if its effect equals that of some serial schedule, in which the transactions run one after another.
- Two operations conflict if they belong to different transactions, access the same item, and at least one of them is a write.
- A schedule is conflict serializable if swapping adjacent non-conflicting operations can turn it into a serial schedule.
- Test: draw a precedence graph with one node per transaction and an edge Ti → Tj whenever an operation of Ti conflicts with a later operation of Tj. The schedule is conflict serializable if and only if the graph has no cycle; a topological order of the graph gives the equivalent serial order.
- View serializability is a broader condition, but testing it is NP-complete.
Example:
time: 1 2 3
T1: R(A) W(A)
T2: W(A)
T1 reads A before T2 writes it (edge T1 → T2), and T2 writes A before T1 writes it (edge T2 → T1). The graph has a cycle, so the schedule is not conflict serializable.