Database Management System 20: Concurrent Execution
Database Management System 20: Concurrent Execution
Database Management System 20: Concurrent Execution
Chittaranjan Pradhan
Schedules
Serializability
Chittaranjan Pradhan
School of Computer Engineering,
KIIT University
20.1
Concurrent Execution
Concurrent Execution
Chittaranjan Pradhan
Concurrent Execution
Concurrent Execution
Schedules
Concurrent execution of transactions means executing more Serial Schedule
Concurrent Schedule
than one transaction at the same time Serializability
Conflict Serializability
Testing for Conflict
In the serial execution, one transaction can start executing only Serializability
View Serializability
after the completion of the previous
20.2
Concurrent Execution
Concurrent Execution...
Chittaranjan Pradhan
Concurrent Execution
T1 transfers Dollar $100 from account A to account B Schedules
T1 Serial Schedule
Concurrent Schedule
Read(A);
Serializability
A:=A-100; Conflict Serializability
B:=B+100;
Write(B);
20.3
Concurrent Execution
Schedules
Chittaranjan Pradhan
Concurrent Execution
Schedules
Serial Schedule
Concurrent Schedule
Schedules Serializability
Conflict Serializability
A schedule is a sequence that indicates the chronological order Testing for Conflict
Serializability
20.4
Concurrent Execution
Serial Schedule
Chittaranjan Pradhan
Concurrent Execution
Schedules
Serial Schedule
Concurrent Schedule
Serial Schedule Serializability
Conflict Serializability
A serial schedule is a schedule where all the instructions Testing for Conflict
Serializability
belonging to each transaction appear together View Serializability
20.5
Concurrent Execution
Serial Schedule...
Chittaranjan Pradhan
T1 T2
Read(A);
A:=A-100; Concurrent Execution
Write(A); Schedules
Read(B); Serial Schedule
B:=B+100; Concurrent Schedule
Write(B);
Schedule1 (T1 followed by T2 ) Read(A);
Serializability
Conflict Serializability
Temp=0.2*A; Testing for Conflict
Serializability
A:=A-Temp;
View Serializability
Write(A);
Read(B);
B:=B+Temp;
Write(B);
T1 T2
Read(A);
Temp=0.2*A;
A:=A-Temp;
Write(A);
Read(B);
B:=B+Temp;
Schedule2 (T2 followed by T1 ) Write(B);
Read(A);
A:=A-100;
Write(A);
Read(B);
B:=B+100;
Write(B);
20.6
Concurrent Execution
Concurrent Schedule
Chittaranjan Pradhan
Schedules
In concurrent schedule, operations from different concurrent Serial Schedule
Serializability
Conflict Serializability
The number of possible schedules for a set of n transactions is Testing for Conflict
Serializability
T1 T2
Read(A);
A:=A-100;
Write(A);
Read(A);
Temp=0.2*A;
A:=A-Temp;
Schedule3 Write(A);
Read(B);
B:=B+100;
Write(B);
Read(B);
B:=B+Temp;
Write(B);
20.7
Concurrent Execution
Concurrent Schedule...
Chittaranjan Pradhan
T1 T2
Read(A);
A:=A-100; Concurrent Execution
Read(A); Schedules
Temp=0.2*A; Serial Schedule
A:=A-Temp; Concurrent Schedule
Write(A);
Schedule4 Read(B);
Serializability
Conflict Serializability
Write(A); Testing for Conflict
Serializability
Read(B);
View Serializability
B:=B+100;
Write(B);
B:=B+Temp;
Write(B);
T1 T2
Read(A);
A:=A-100;
Write(A);
Read(A);
Temp=0.2*A;
A:=A-Temp;
Schedule5 Read(B);
B:=B+100;
Write(A);
Read(B);
B:=B+Temp;
Write(B);
Write(B);
20.8
Concurrent Execution
Serializability
Chittaranjan Pradhan
Concurrent Execution
Serializability Schedules
Serial Schedule
Serializability
serial schedule Conflict Serializability
Testing for Conflict
Serializability
20.9
Concurrent Execution
Serializability...
Chittaranjan Pradhan
Concurrent Execution
T1 T2 T1 T2
Read(A); Read(A); Schedules
Serial Schedule
Write(A); Write(A); Concurrent Schedule
Read(B); Read(B);
Serializability
Write(B); Write(B); Conflict Serializability
Read(A); Read(A); Testing for Conflict
Write(A); Write(A); Serializability
View Serializability
Read(B); Read(B);
Write(B); Write(B);
Schedule1 Schedule2
T1 T2 T1 T2 T1 T2
Read(A); Read(A); Read(A);
Write(A); Read(A); Write(A);
Read(A); Write(A); Read(A);
Write(A); Read(B); Read(B);
Read(B); Write(A); Write(A);
Write(B); Read(B); Read(B);
Read(B); Write(B) Write(B);
Write(B); Write(B); Write(B);
Schedule3 Schedule4 Schedule5
20.10
Concurrent Execution
Conflict Serializability
Chittaranjan Pradhan
Conflict Serializability
Concurrent Execution
Conflict Serializability consists of conflicting operations
Schedules
Let us consider a schedule S in which there are two Serial Schedule
Serializability
respectively (i6=j) Conflict Serializability
Testing for Conflict
Serializability
If Ii and Ij access different data items, then we can swap Ii and View Serializability
Concurrent Execution
Thus, Ii and Ij conflict if they are the instructions by different Schedules
transactions on the same data item, and at least one of these Serial Schedule
Concurrent Schedule
20.12
Concurrent Execution
Conflict Serializability...
Chittaranjan Pradhan
Concurrent Execution
Schedules
Serial Schedule
Concurrent Schedule
Serializability
Conflict Serializability
T1 T2 T1 T2 T1 T2 Testing for Conflict
Serializability
Read(A); Read(A); Read(A); View Serializability
Write(A); Read(A); Write(A);
Read(B); Write(A); Read(B);
Write(B); Write(A); Read(A);
Read(A); Read(B); Write(A);
Write(A); Read(B); Read(B);
Read(B); Write(B) Write(B);
Write(B); Write(B); Write(B);
Schedule3 Schedule4 Schedule5
20.13
Concurrent Execution
Conflict Serializability...
Chittaranjan Pradhan
It is possible to have two schedules that produce the same
outcome, but that are not conflict equivalent
Concurrent Execution
T1 T5
Schedules
Read(A); Serial Schedule
A:=A-100; Concurrent Schedule
Write(A); Serializability
Read(B); Conflict Serializability
B:=B-200; Testing for Conflict
Serializability
Write(B);
View Serializability
Read(B);
B:=B+100;
Write(B);
Read(A);
A:=A+200;
Write(A);
Schedule6
T1 T5
Read(A);
Write(A);
Read(B);
Write(B);
Read(B);
Write(B);
Read(A);
Write(A);
Schedule6
20.14
Concurrent Execution
Testing for Conflict Serializability
Chittaranjan Pradhan
Schedules
Construct a directed graph, called a precedence graph from S. Serial Schedule
Concurrent Schedule
This graph consists of a pair G = (V, E), where V is a set of Serializability
vertices and E is a set of edges Conflict Serializability
Testing for Conflict
Serializability
View Serializability
The set of vertices consists of all the transactions participating
in the schedule
20.15
Concurrent Execution
Testing for Conflict Serializability...
Chittaranjan Pradhan
If the precedence graph for a concurrent schedule S has a
cycle, then that schedule is not conflict serializable. If the
Concurrent Execution
graph contains no cycles, then the schedule S is conflict
Schedules
serializable Serial Schedule
Concurrent Schedule
Serializability
Conflict Serializability
Testing for Conflict
Serializability
View Serializability
20.16
Concurrent Execution
View Serializability
Chittaranjan Pradhan
View Serializability
Concurrent Execution
Concurrent Execution
Schedules
T1 T2 T3 Serial Schedule
Concurrent Schedule
Read(Q);
Serializability
Schedule7 Write(Q); Conflict Serializability
Write(Q); Testing for Conflict
Serializability
Write(Q); View Serializability
20.18