


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Huan; Class: Introductn to Database Systems; Subject: Elect Engr & Computer Science; University: University of Kansas; Term: Spring 2009;
Typology: Study notes
1 / 26
This page cannot be seen from the preview
Don't miss anything!



















4/26/
Luke Huan Univ. of Kansas
2
z
4/26/
Luke Huan Univ. of Kansas
4
1
2
T^1 T^2
Read 100 Write 100+
Read 101Write 1012Read 100Write 100
Read 200 Write 200+
Add 1 to both
A
and
B
(preserve
A
= B
)
Multiply both
A
and
B
by 2
(preserves
A
= B
)
A^
≠^
B!
4/26/
Luke Huan Univ. of Kansas
5
z
Phase 1: obtain locks, phase 2: release locks
T^1
T^2
r(
A ) w(
A )
r(
A ) w(
A ) r(
B ) w(
B )
r(
B ) w(
B )
lock-X(
A )
lock-X(
B )
unlock(
B )
unlock(
A )
lock-X(
A )
lock-X(
B ) Cannot obtain the lock on
B
until
T
unlocks 1
T^1
T^2
r( A ) w(
A )
r( A ) w(
A )
r( B ) w(
B )
r( B ) w(
B )
4/26/
Luke Huan Univ. of Kansas
7
z
A writer will block all other readers until the writercommits or aborts
)
4/26/
Luke Huan Univ. of Kansas
8
z
4/26/
Luke Huan Univ. of Kansas
10
Unlock(A)Read(B)Unlock(B) PRINT(A+B)
Read(B)B := B +50Write(B)Unlock(B)
Read(A)Lock_S(B)
A: = A-50Write(A)Lock_X(B)Unlock(A)
Lock_S(A)
Lock_X(A)Read(A)
2PL, A= 1000, B=2000, Output =?
4/26/
Luke Huan Univ. of Kansas
11
Read(A)Lock_S(B)Read(B)PRINT(A+B)Unlock(A) Unlock(B)
A: = A-50Write(A)Lock_X(B)Read(B)B := B +50Write(B)Unlock(A)Unlock(B)
Lock_S(A)
Strict 2PL, A= 1000, B=2000, Output =?Lock_X(A)Read(A)
Does any other xact hold a conflicting lock? z
If no, grant the lock. z
If yes, put requestor into wait queue.
z
Shared lock can request to upgrade to exclusive
z
z
Deadlock!
z
z
z
z
z
Transactions may abort (“Rollback”).
z
What if DBMS stops running? (Causes?)
-^
-^
Abort
Commit
Commit
4/26/
Luke Huan Univ. of Kansas
20
z
z
How do we undo
T
(atomicity)?
z
z
How do we complete
T
(durability)?