Professional Documents
Culture Documents
Database System Concepts - 6th Edition 14.14 ©Silberschatz, Korth and Sudarshan
Testing for Conflict Serializability
A schedule is conflict serializable if and only if its
precedence graph is acyclic.
To test for conflict serializability, we need to
construct the precedence graph and to invoke a
cycle-detection algorithm
Cycle-detection algorithms exist which take order
n2 time, where n is the number of vertices in the
graph.
(Better algorithms take order n + e where e is
the number of edges.)
If precedence graph is acyclic, the serializability
order can be obtained by a topological sorting of
the graph.
That is, a linear order consistent with the
partial order of the graph.
For example, a serializability order for the
schedule (a) would be one of either (b) or (c)
Database System Concepts - 6th Edition 14.16 ©Silberschatz, Korth and Sudarshan
Example (Serializability)
We now present a simple and efficient method for determining conflict serializability
of a schedule. Consider a schedule S. We construct a directed graph,
called a precedence graph, fromS. This graph consists of a pair G = (V, E),
where V is a set of vertices and E is a set of edges. The set of vertices consists of
all the transactions participating in the schedule.
Database System Concepts - 6th Edition 14.17 ©Silberschatz, Korth and Sudarshan
Cycle-detection Algorithms
To test for conflict serializability, we need to construct the precedence
graph and to invoke a cycle-detection algorithm.
Cycle-detection algorithms, such as those based on depth-first search,
require on the order of n2 operations, where n is the number of
vertices in the graph (that is, the number of transactions).
Database System Concepts - 6th Edition 14.18 ©Silberschatz, Korth and Sudarshan
Example
consider transaction T5, which transfers $10 from account B to account A. Let schedule 8
be as defined in below figure, We claim that schedule 8 is not conflict equivalent to the
serial schedule <T1,T5>, since, in schedule 8, the write(B) instruction of T5 conflicts with
the read(B) instruction of T1. This creates an edge T5 → T1 in the precedence graph.
Similarly, we see that the write(A) instruction of T1 conflicts with the read instruction of T5
creating an edge T1 → T5. This shows that the precedence graph has a cycle and
that schedule 8 is not serializable.
Figure: schedule 8
Database System Concepts - 6th Edition 14.19 ©Silberschatz, Korth and Sudarshan
Example
Database System Concepts - 6th Edition 14.20 ©Silberschatz, Korth and Sudarshan
Recoverable Schedules
If T8 should abort, T9 would have read (and possibly shown to the user)
an inconsistent database state. Hence, database must ensure that
schedules are recoverable.
Database System Concepts - 6th Edition 14.21 ©Silberschatz, Korth and Sudarshan
Cascading Rollbacks
Cascading rollback – a single transaction failure leads to a
series of transaction rollbacks. Consider the following schedule
where none of the transactions has yet committed (so the
schedule is recoverable)
Database System Concepts - 6th Edition 14.22 ©Silberschatz, Korth and Sudarshan
Cascadeless Schedules
Database System Concepts - 6th Edition 14.23 ©Silberschatz, Korth and Sudarshan