0% found this document useful (0 votes)
21 views6 pages

LOCKING

The document describes the 2PL concurrency control protocol and its disadvantages like irreconcilable schedules and deadlocks. It then discusses strict 2PL and rigorous 2PL protocols to remove these disadvantages, as well as lock conversion and timestamp-based deadlock handling techniques.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views6 pages

LOCKING

The document describes the 2PL concurrency control protocol and its disadvantages like irreconcilable schedules and deadlocks. It then discusses strict 2PL and rigorous 2PL protocols to remove these disadvantages, as well as lock conversion and timestamp-based deadlock handling techniques.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

2PL

T1 T2 T1 T2
X(A)
Lock S(A)
R(A)
W(A) Lock S(A)
S(A) Lock X(B)
R(A)
X(B) *

R(B) Unlock(A)
U(A)
Unlock(B) Lock x(D)

*
*Lock point Unlock(A)

Unlock(D)

DISADVANTAGES OF 2PL:
IRRECOVERABLE SCHEDULE: DEADLOCK

T1 T2 T1 T2
X(A) X(A)
R(A) R(A)
W(A) W(A)
U(A) X(B)
S(A)
R(A)
R(A)
W(A)
COMMIT
WAIT X(B)
FAILURE
X(A)

WAIT
CASCADING ROLLBACK STARVATION

T1 T2 T3 T4 T1 T2 T3 T4
X(A) S(A)
X(A) .
R(A) . S(A)
W(A) . .
U(A) .
U(A)
. S(A)
S(A) U(A) .
R(A) S(A) .
.
R(A) S(A)
U(A)
R(A)
FAILURE

STRICT 2PL RIGOROUS 2PL


TO REMOVE IRRECOVERABILITY AND CASCADING ROLLBACK

STRICT 2PL: RIGOROUS 2PL:

T1 T2 T1 T2
S(A) S(A)
X(B) X(B)
R(A) R(A)
U(A) R(B)
R(B) W(B)
W(B) COMMIT
COMMIT U(B)
U(B) U(A)
X(B) X(B)
W(B) W(B)
COMMIT COMMIT
U(B) U(B)
LOCK CONVERSION:

T8 T9
Lock x(a1) Read (a1) Read (a1)
Read (a2) Read (a2)
. Display (a1+a2)
.
.
Read (an)
Write (a1)

Lock s(a1)
T8 T9
Read (a1) Read (a1)
Read (a2) Read (a2)
. Display
(a1+a2)
.
.
Lock X(a1) Read (an)
Write (a1)

DEADLOCK HANDLING:

DEADLOCK PREVENTION (based on timestamp)

1. WAIT-DIE SCHEME

2. WOUND- WAIT SCHEME


1. WAIT-DIE SCHEME:

IF TS(Ti) < TS(Tj)

Ti wait

ELSE

Ti rollback

2. WOUND- WAIT SCHEME

IF TS(Ti) > TS(Tj)

Ti wait

ELSE

Tj rollback

TIME STAMP BASED PROTOCOL


10:00 10:10
T1 T2
100 200
OLDER YOUNGER

READ-TS: last trans which has performed read successfully: RTS(A)=30

10 20 30
T1 T2 T3
R(A)
R(A)
R(A)
WRITE-TS: last trans which has performed write successfully: WTS(A)=20

10 20 30
T1 T2 T3
W(A)
W(A)
W(A)

RULES:
T1 T2 T1 T2 T1 T2
(old) (younger) (old) (younger) (old) (younger)
R(A) W(A) W(A)
W(A) R(A) W(A)

1) Transaction Ti issues a READ(A) operation

a) WTS(A) > TS(Ti) rollback Ti T1 T2


(old) (younger)
W(A)
R(A)
b)set RTS(A)= max{RTS(A),TS(Ti)}
2) Transaction Ti issues a WRITE(A) operation

a) RTS(A) > TS(Ti) rollback Ti

T1 T2
(old) (younger)
R(A)
W(A)

b) WTS(A) > TS(Ti) rollback Ti

T1 T2
(old) (younger)
W(A)
W(A)

c) set WTS(A)=TS(Ti)

You might also like