Академический Документы
Профессиональный Документы
Культура Документы
Concurrency Control:
Meaning of serializability
Granularity of locking
Recovery Control:
Purpose of check-pointing
Transaction Support
Transaction
Action,
Logical
Application
program
is
series
of
transactions with non-database processing
in between.
Transforms
Kyanganda Sam
Example Transaction
Kyanganda Sam
Transaction Support
Can have one of two outcomes:
Success
Failure
Such
Kyanganda Sam
Kyanganda Sam
Properties of Transactions
Four basic (ACID) properties of a transaction
are:
Isolation Partial
effects
of
incomplete
transactions should not be visible to other
transactions.
Durability Effects of a committed transaction
are permanent and must not be lost because of
later failure.
ICS 2415 Advanced Dbase Systems
Kyanganda Sam
Kyanganda Sam
Concurrency Control
Process
of
managing
simultaneous
operations on the database without having
them interfere with one another.
Kyanganda Sam
caused by concurrency:
Kyanganda Sam
completed update
overridden by another user.
is
10
10
Kyanganda Sam
11
11
Kyanganda Sam
12
12
Kyanganda Sam
13
13
Kyanganda Sam
unrepeatable read.
14
Kyanganda Sam
15
15
Kyanganda Sam
Serializability
Objective of a concurrency control protocol
transactions
consistency.
guaranteed
to
ensure
16
16
Kyanganda Sam
Serializability
Schedule
Sequence of reads/writes
concurrent transactions.
by
set
of
Serial Schedule
Schedule where operations of each
transaction are executed consecutively
without any interleaved operations from
other transactions.
No guarantee that results of all serial
17
Kyanganda Sam
Non-serial Schedule
Schedule where operations from set of
18
Kyanganda Sam
Serializability
In serializability, ordering of read/writes
is important:
19
Kyanganda Sam
20
20
Kyanganda Sam
Serializability
Conflict serializable schedule orders any
21
21
Kyanganda Sam
Precedence Graph
Create:
22
22
Kyanganda Sam
accounts by 10%.
not serializable.
23
23
Kyanganda Sam
24
24
Kyanganda Sam
View Serializability
Offers less stringent definition of schedule equivalence than
conflict serializability.
Two schedules S1 and S2 are view equivalent if:
schedule.
Every conflict serializable schedule is view serializable,
although converse is not true.
It can be shown that any view serializable schedule that is not
conflict serializable contains one or more blind writes.
In general, testing whether schedule is serializable is NPcomplete
25
25
Kyanganda Sam
26
26
Kyanganda Sam
Recoverability
Serializability
27
27
Kyanganda Sam
Recoverable Schedule
28
28
Kyanganda Sam
Locking,
Timestamping.
conflicts at commit.
29
29
Kyanganda Sam
Locking
30
30
Kyanganda Sam
31
31
Kyanganda Sam
is:
32
32
Kyanganda Sam
33
33
Kyanganda Sam
34
34
Kyanganda Sam
35
35
Kyanganda Sam
36
36
Kyanganda Sam
Preventing
Uncommitted
Problem using 2PL
Dependency
37
37
Kyanganda Sam
38
38
Kyanganda Sam
Cascading Rollback
If every transaction in a schedule follows 2PL, schedule is
serializable.
be released.
39
39
Kyanganda Sam
Cascading Rollback
Transactions conform to 2PL.
T14 aborts.
Since T15 is dependent on T14, T15 must also be rolled
40
40
Kyanganda Sam
Concurrency
Structures
Control
with
Index
Could treat each page of index as a data item and apply 2PL.
However, as indexes will be frequently accessed, particularly higher
Suggests only have to exclusively lock leaf node in such a case, and
41
Kyanganda Sam
41
Concurrency
Structures
Control
with
Index
42
42
Kyanganda Sam
Deadlock
An impasse that may result when two (or more) transactions
are each waiting for locks held by the other to be released.
43
43
Kyanganda Sam
Deadlock
Only one way to break deadlock: abort one or
Timeouts.
Deadlock prevention.
44
44
Kyanganda Sam
Timeouts
Transaction that requests lock will only wait
45
45
Kyanganda Sam
Deadlock Prevention
DBMS looks ahead to see if transaction would cause
Could
order
timestamps:
transactions
using
transaction
46
46
Kyanganda Sam
breaks it.
47
47
Kyanganda Sam
48
48
Kyanganda Sam
of deadlock victim;
avoiding
starvation.
49
49
Kyanganda Sam
Time-stamping
Transactions ordered globally so that older transactions, transactions
Timestamp
Read/write proceeds only if last update on that data item was carried
50
50
Kyanganda Sam
Time-stamping - Read(x)
Consider a transaction T with timestamp ts(T):
x already
transaction.
updated
by
younger
(later)
51
Kyanganda Sam
Timestamping - Write(x)
ts(T) < write_timestamp(x)
52
52
Kyanganda Sam
53
53
Kyanganda Sam
Comparison of Methods
54
54
Kyanganda Sam
55
55
Kyanganda Sam
Optimistic Techniques
Based on assumption that conflict is rare and more
Read
Validation
Write
56
56
Kyanganda Sam
commit.
57
57
Kyanganda Sam
58
58
Kyanganda Sam
the database.
59
59
Kyanganda Sam
A file.
A record.
Tradeoff:
60
Kyanganda Sam
Hierarchy of Granularity
Could represent granularity of locks in a
hierarchical structure.
also locked.
granting lock.
61
61
Kyanganda Sam
Hierarchy of Granularity
Intention lock could be used to lock all ancestors of a
locked node.
62
62
Kyanganda Sam
Levels of Locking
63
63
Kyanganda Sam
Database Recovery
Process of restoring database to a
correct state in the event of a failure.
Need for Recovery Control
64
Kyanganda Sam
Types of Failures
System crashes, resulting in loss of main
memory.
secondary storage.
data or facilities.
Sabotage.
65
65
Kyanganda Sam
durability.
undone.
66
Kyanganda Sam
Example
67
Kyanganda Sam
Recovery Facilities
DBMS should provide following facilities to
68
68
Kyanganda Sam
Log File
Contains information about all updates to database:
Transaction records.
Checkpoint records.
Transaction identifier.
69
Kyanganda Sam
70
70
Kyanganda Sam
Log File
Log file may be duplexed or triplexed.
Log file sometimes split into two separate
random-access files.
overall performance.
71
71
Kyanganda Sam
Checkpointing
Checkpoint
transactions.
When failure occurs, redo all transactions that committed since
the checkpoint and undo all transactions active at time of
crash.
In previous example, with checkpoint at time tc, changes made
Thus:
72
Kyanganda Sam
Recovery Techniques
If database has been damaged:
73
73
Kyanganda Sam
Update
Immediate
Shadow
Update
Paging
74
74
Kyanganda Sam
Deferred Update
Updates
75
Kyanganda Sam
Immediate Update
Updates are applied to database as they occur.
following a failure.
76
76
Kyanganda Sam
Shadow Paging
Maintain two page tables during life of a
same.
Shadow
During
table
77
77
Kyanganda Sam
Protocols considered so far are suitable for types of transactions that arise in
traditional business applications, characterized by:
Sagas
Dynamic Restructuring
Workflow Models
78
78
Kyanganda Sam
79
Kyanganda Sam
80
80
Kyanganda Sam
transaction
can
be
decomposed into number of subtransactions
for purposes of concurrency and recovery.
Intra-transaction parallelism.
81
81
Kyanganda Sam
82
82
Kyanganda Sam
Sagas
83
Kyanganda Sam
subtransactions is balanced.
Nodes at same depth of tree correspond to operations of
same level of abstraction in DBMS.
Edges represent implementation of an operation by
84
84
Kyanganda Sam
85
85
Kyanganda Sam
86
86
Kyanganda Sam
Dynamic Restructuring
To address constraints imposed by ACID properties of flat transactions,
and divides its actions and resources (for example, locked data items)
between new transactions.
Resulting transactions proceed independently.
Allows partial results of transaction to be shared, while still preserving
its semantics.
Can be applied only when it is possible to generate two transactions that
are serializable with each other and with all other concurrently
executing transactions.
Conditions that permit transaction to be split into A and B are:
.AWriteSet BWriteSet BWriteLast.
If both A and B write to same object, Bs write operations must
follow As write operations.
.AReadSet BWriteSet = .
A cannot see any results from B.
.BReadSet AWriteSet = ShareSet.
B may see results of A.
87
87
Kyanganda Sam
Dynamic Restructuring
These guarantee that A is serialized before B.
However, if A aborts, B must also abort.
If both BWriteLast and ShareSet are empty, then A
join-transaction
Adaptive recovery.
Reducing isolation.
88
88
Kyanganda Sam
Workflow Models
Has been argued that above models are still not powerful to
More
that
are
Workflow
systems
to
automate
89
89
Kyanganda Sam