Professional Documents
Culture Documents
General Overview
Relational model - SQL
Indexing
Query Processing and Optimization Transaction Processing and CC
Review: AC[I]D
Isolation
Multiple-Granularity Locks
tables).
Shouldnt have to decide! Data containers are nested:
Pages Tuples
--
IS IX S
IS IX S
Parent locked in
P C
IS IX S SIX X
IS, S IS, S, IX, X, SIX [S, IS] not necessary X, IX, [SIX] none
R1
t1
t2
T1(S)
t3
t4
T2(X)
T1(IX)
Examples
R
T1(IS)
R t3 t4
T1(S)
T1(IX)
t1
T1(X)
f2.1
t2
t1
t2
t3
t4
f2.2
f4.2
T1(SIX)
R
T1(IX)
t2
t3
t4
f2.2
f4.2
f4.2
Examples
T1 scans R, and updates a few tuples:
T1 gets an SIX lock on R, then repeatedly gets an S lock on tuples of R, and occasionally upgrades to X on the tuples that needs to update.
T2 uses an index to read only part of R:
- IS IX S
IS IX S
Set S locks
Set SIX locks
Set X locks
Optimistic CC
Locking is a conservative approach in which conflicts are
prevented. Disadvantages:
Lock management overhead. Deadlock detection/resolution. Lock contention for heavily used objects.
If conflicts are rare, we might be able to gain concurrency by not
Timestamp-Based Protocols
Idea:
Decide in advance ordering of xctions Ensure concurrent schedule serializes to serial order decided
Timestamps
Timestamp CC
Idea: If action pi of Xact Ti conflicts with action qj of Xact Tj, and TS(Ti) < TS(Tj), then pi must occur before qj. Otherwise, restart violating Xact.
of O.
So, abort T and restart it with a new, larger TS. (If restarted with same TS, T will fail again!)
If TS(T) > W-TS(O):
T start
U start
T start
U start
T1 W(A)
T2
R(A) W(B) Commit
Buffer all writes until writer commits (but update WTS(O) when the write is allowed.) Block readers T (where TS(T) > WTS(O)) until writer of O commits.
Similar to writers holding X locks until commit, but still not quite 2PL.