Documente Academic
Documente Profesional
Documente Cultură
CC.Lecture 1
Transactions
DBMS actions:
reads, writes
special actions: commit, abort
for now, assume reads and writes are on tuples;
well revisit this assumption later.
Concurrency Control
guarantees Consistency and Isolation
Well do C. C. first:
what problems could arise?
what is acceptable behavior?
how do we guarantee acceptable behavior?
Schedules
Acceptable Schedules
Serializable schedules:
final state is what some serial schedule would
have produced
aborted Xacts are not part of schedule, ignore
them for now.
transfer
$100
from A
to B
Serializability Violations
add 6%
interest
to A & B
Database
is
inconsiste
nt!
More Conflicts
Two Issues:
How does one undo the effects of an xact?
well cover this in logging/recovery
What if another Xact sees these effects??
10
Cascading Aborts
11
Degrees of Consistency
12
Consistency: Defn 1
No
No
No
No
13
Precedence Graph
14
Conflict Serializability
15
Defn 2 (ignore
Recoverability)
16
--
S
suspended until it can be granted
X
Introduction to Database Systems
17
2PL:
if T wants to read an object, first obtains an S
lock
if T wants to modify an object, first obtains X
lock
If T releases any lock, it can acquire no new
locks!
lock point
Locks are automatically obtained by DBMS
Guarantees Serializability!!
# of
why?
locks
growing phase
shrinking
phase
Time
18
Strict 2PL
Strict 2PL:
if T wants to read an object, first obtains an
S lock
if T wants to modify an object, first obtains
X lock
Hold all locks until end of transaction
# of
locks
Time
19
Degree 3
long X lock on data written
long S lock on data read
Degree 2 :
long X lock on data written
short S lock on data read
Degree 1 :
long X lock on data written
Degree 0 :
short X lock on data written
20
21
Lock Manager
Implementation
OID
Lock Mode
List: Xacts holding lock
List: Wait Queue
22
Mode==X
Currently Locked?
No
Yes
Currently X?
Yes
No
Put on Queue
No
Grant Lock
Introduction to Database Systems
23
24
Deadlock
25
Deadlock Prevention
26
An Alternative to Prevention
27
Deadlock Detection
28
29
Multiple-Granularity Locks
contains
Tables
Pages
Tuples
30
--
IS IX S
IS
IX
--
S
X
31
Summary of C.C.
32
Summary, cont.
33