Chameli Devi Group of Institutions: Cs502 Dbms Unit-4 Concurrency Control
Chameli Devi Group of Institutions: Cs502 Dbms Unit-4 Concurrency Control
INSTITUTIONS
CS502 DBMS
Unit- 4
Concurrency Control
Presented By:
Miss. Renu Jaiswal
Assistant Professor
CSE Department
Ms. Renu Jaiswal 1
Concurrency Control and Recovery
• In real life:
• users access the database concurrently, and
• systems crash.
• Concurrent access to the database also improves performance,
yields better utilization of resources.
if (!occ) {
EXEC SQL UPDATE Flights
SET occupied = ‘true’
WHERE fltNum= :flight AND fltdt= :date AND fltSeat=:seat
/* more code missing */
}
else /* notify customer that seat is not available */
In SQL:
In SQL:
SET TRANSACTION
ISOLATION LEVEL READ UNCOMMITTED
• Locking
• Lock manager
• 2 Phase Locking
• Deadlocks:
• Prevention
• Detection
• Note: there are many possible serial schedules. Each one is OK. The
DBMS does not provide any guarantee in which order concurrently
submitted transactions are executed.
Serializable schedules:
S Ö Ö
X Ö
Mode==X Mode==S
Yes
No
Put on Queue No
Grant Lock
• Why??
lock point
# of
lock
s shrinking
phase
growing phase
Ms. Renu Jaiswal 18
Time
Serializability Graphs
Two actions conflict if they access the same data item.
T1 T2
Ms. Renu Jaiswal 19
Conflict Serializability
• 2 schedules are conflict equivalent if:
– they have the same sets of actions, and
– each pair of conflicting actions is ordered in the same way.
• A schedule is conflict serializable if it is conflict equivalent to a serial schedule.
– Note: Some serializable schedules are not conflict serializable!
• Theorem: A schedule is conflict serializable iff its precedence graph is acyclic.
• Theorem: 2PL ensures that the precedence graph will be acyclic!
Possible solutions:
pageLSN
“Log tail”
in RAM