DB2 L03 Transactions
DB2 L03 Transactions
DB2 L03 Transactions
11
Outline
Transaction and System Concepts
Desirable Properties of Transactions
Characterizing Schedules based on
Recoverability
Characterizing Schedules based on
Serializability
Transaction Support in SQL
22
Multiuser System:
Many users can access the system concurrently.
Concurrency
Interleaved processing:
Concurrent execution of processes is interleaved in a single
CPU
Parallel processing:
Processes are concurrently executed in multiple CPUs.
33
44
55
66
77
88
99
10
10
11
11
12
12
13
13
14
14
15
15
Transaction states:
Active state
Partially committed state
Committed state
Failed state
Terminated State
16
16
17
17
18
18
19
19
20
20
21
21
22
22
23
23
2.
24
24
25
25
26
26
27
27
28
28
29
29
30
30
Check conflicts
<r1(X), w2(X)>, <r2(X), w1(X)>, <w1(X), w2(X)>, <r1(X), r2(X)
31
31
2.
3.
32
32
Sa
is not
recoverable,
even
though
it suffers
from X
lost
update
S
recoverable,
recoverable,
because
because
T1 commits
T2
readsbefore
item
T2
from
T1 problem.
c is
d
DB Systems 2 (Spring 2016)
33
33
34
34
35
35
Serial schedule:
A schedule S is serial if, for every transaction T
participating in the schedule, all the operations
of T are executed consecutively in the
schedule.
Otherwise, the schedule is called nonserial
schedule.
Serializable schedule:
A schedule S is serializable if it is equivalent to
some serial schedule of the same n
transactions.
DB Systems 2 (Spring 2016)
36
36
Result equivalent:
Two schedules are called result equivalent if they
produce the same final state of the database.
Conflict equivalent:
Two schedules are said to be conflict equivalent if the
order of any two conflicting operations is the same in
both schedules.
Conflict serializable:
A schedule S is said to be conflict serializable if it is
conflict equivalent to some serial schedule S.
37
37
38
38
39
39
40
40
Practical approach:
Come up with methods (protocols) to ensure
serializability.
Its not possible to determine when a schedule
begins and when it ends.
Hence, we reduce the problem of checking the whole
schedule to checking only a committed project of the
schedule (i.e. operations from only the committed
transactions.)
41
41
View equivalence:
A less restrictive definition of equivalence of
schedules
View serializability:
Definition of serializability based on view
equivalence.
A schedule is view serializable if it is view
equivalent to a serial schedule.
DB Systems 2 (Spring 2016)
42
42
2.
3.
43
43
44
44
45
45
46
46
47
47
Recall
48
48
49
49
50
50
YZ
DB Systems 2 (Spring 2016)
51
51
YZ
52
52
53
53
54
54
55
55
Nonrepeatable Read:
Allowing another transaction to write a new value between
multiple reads of one transaction.
A transaction T1 may read a given value from a table. If another
transaction T2 later updates that value and T1 reads that value
again, T1 will see a different value.
Consider that T1 reads the employee salary for Smith. Next,
T2 updates the salary for Smith. If T1 reads Smith's salary
again, then it will see a different value for Smith's salary.
56
56
57
57
58
58
59
59
Summary
Transaction and System Concepts
Desirable Properties of Transactions
Characterizing Schedules based on
Recoverability
Characterizing Schedules based on
Serializability
Transaction Support in SQL
60
60