Introduction To Real-Time Databases: (Embedded Systems and Wireless Networking Laboratory)
Introduction To Real-Time Databases: (Embedded Systems and Wireless Networking Laboratory)
Real-Time Databases
[email protected]
Reading:
Kam-yiu Lam and Tei-Wei Kuo, Real-Time Database Systems: Architecture and Techniques, Kluwer Academic Publishers, 2000
1
Krishna and Kang, Real-TimeSystems, McGRAW-HILL, 1997.
Introduction
Introduction
value
No deadline violation
deadline
value
deadline
value
deadline
3
Introduction
Design Issues
Real-Time Concurrency Control
Optimistic vs Conservative CC
Index
Distributed RTDBMS
Data Replication
Commit Processing
Mobile RTDBMS
etc
4
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
Checklist
What should we really know about the design issues of
real-time databases?
What is known about concurrency control of real-time
data access?
What is known about real-time recovery?
Why is it so hard to have response-time predictability?
What is main-memory database? Is it useful to RTDB?
What is known about real-time query optimization?
What is known about availability issues, real-time file
systems, and disk management?
5
Typical Schedule
T1 (x=x-100, y=y+100)
r(x)
w(x)
T2
r(x)
r(y)
r(y)
w(y)
9
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
Correctness Criteria
Conventional Criteria:
Final-State Serializability ~ NP-hard
Generate the same final state as a serial schedule does.
11
Examples: Serializability
S = R1(X)W1(X) R2(X)R2(Y)W2(Y) W1(Y)
S is final-state equivalent to S1 = 2 1
S is not view equivalent to S1 because of the transaction
view of 2, which is a dead transaction.
S = R1(Y) R3(W) R2(Y) W1(Y)W1(X) W2(X)W2(Z) W3(X)
S is view equivalent to S1 = 2 1 3.
1
Y
S is not conflict equivalent to S1
X
X
because of the order of the two dead
2
W(X)s of 1 and 2.
3
X
12
Cancellation
Cancel a seat on the flight.
If the number of reservations drops below 85, assign only3
flight attendants to the flight.
13
Consistency Constraints
In conventional databases,
Internal Consistency
Database satisfies consistency and integrity constraints, e.g.,
x=y.
Relative/Temporal Consistency
The ages of two data are within a tolerable length of time.
For example, the temperature and the pressure of a boiler read
14
at time t.
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
@ all rights
for Tei-Wei
Kuo,logging
National
Taiwan
University
Onlypreserved
bad for disk-based
databases,
purpose,
or virtual
memory usage.
2
16
Optimistic Mechanism
Three phases for each transaction execution:
read, validation, write
etc
etc.
19
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
Characteristics
A typical way for pessimistic concurrency control
Prevention of serializability violation by lock
management - possibly lengthy blocking time
An Example Protocol
Two-phase locking + A Priority Assignment
Scheme, such as RM or EDF.
Two-phase locking growing phase and shrinking
phase
priority inheritance.
21
22
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
23
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
Ceiling rule
A transaction may lock a data object if its
priority is higher than the highest RWPLi of
data objects locked by other transactions.
24
RWPCP
1
APL1 = 1
WPL1= 2
APL2 = 2
WPL2= 3
UL(S1)
RL(S1)
10
12
14
16
18
20
22
24
26
28
30
UL(S2)
WL(S1)
RL(S2)
10
UL(S1)
12
14
16
18
20
22
24
26
28
30
12
14
16
18
20
22
24
26
28
30
UL(S2)
WL(S2)
3
0
10
S1
S2
S1&S2
25
Properties of RWPCP
26
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
WL(S1)
UL(S1)
1
2
6
RL(S1)
10
10
12
UL(S1)
14
16
18
14
16
18
S1
S2
12
APL1 = 1
WPL1= 1
APL2 = 2
WPL2= null
APL3 = 2
WPL3= null
S3
RL(S2)
Processor 2
RL(S3)
UL(S3)
UL(S2)
2
2
RL(S1)
4
6
UL(S1)
10
12
14
16
18
10
12
14
16
18
4
2
An Observation
The number of priority inversion may be
more than one when there are more
than one processor in the system!
28
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
Why?
29
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
30
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
Lock Modes
Working/Consistent Versions
Writes on working versions
Reads from consistent versions
Read/Write/Certify Locks
31
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
Ceiling rule
A transaction may lock a data object if its
priority is higher than the highest RWPLi of
data objects locked by other transactions.
32
Certify
Blocked
Blocked
Blocked
Remark:
More versions?
Aborting allowed?
33
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
2VPCP
1
RL(S1)
10
12
APL1 = 1
WPL1= 2
APL2 = 2
WPL2= 3
UL(S1)
14
16
18
20
22
24
26
28
30
26
28
30
28
30
UL(S2)
WL(S1) RL(S2)
UL(S1)
10
12
14
16
18
20
22
24
UL(S2)
WL(S2)
3
0
10
12
14
16
18
20
22
24
S1
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
26
S2
S1&S2
34
Properties of 2VPCP
Properties
Lemma1: No transitive blocking (L->M->H)
Theorem 1: One priority inversion per
transaction.
Theorem 2 : Deadlock-freeness
Theorem 4: Serializable schedules if the twophase-locking scheme (2PL) is followed.
35
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
Simulation Results
36
Simulation Results
38
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
Main Idea:
When a lower priority transaction introduces excessive
blocking to a higher priority transaction, then higher
priority transaction will abort the lower priority
transaction.
Compatible Modules:
Priority Ceiling Protocol (PCP)
2PL
A simple aborting mechanism
Reference: Tei-Wei Kuo, Ming-Chung Liang, and LihChyun Shu, Abort-Oriented Concurrency Control for Real-Time Databases,
IEEE Transactions on Computers (SCI), Vol. 50, No. 7, July 2001, pp. 660-673.
39
BAP Schedule
TH ( 5,11)
TM (5,19)
TL ( 7,22)
41
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
PCP+2PL Schedule
TH (5,11)
TM (5,19)
TL ( 7,22)
42
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
Properties
Schedulability Analysis
t
(
i HPC j p cost i , j )
i
Lemma 3. A transaction i scheduled by BAP will always meet its
( k , m) Ri
such
mpk
) + ci + bi + abi mpk
p
j
(c j
jHPCi
where b and ab are the worst case blocking cost and aborting cost of
i
i
transaction i ,
p
Ri = {( k , m) 1 k i, m = 1, 2, ..., i }
pk
44
ab
i
i
p j
Extensions of BAP
Extensions of BAP
AMB i = ( d i t )
di t
c j ) c i ab i ( t )
p
(
j HPC
di t
cost i , j )
p
i
abi ( t ) = HPC (
i
j
48
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
Performance Evaluation
Case Study
Generic Avionics Platform
18 periodic transactions.
9 data objects.
Olympus AOCS
10 periodic transactions.
4 sporadic transactions.
17 data objects.
Simulation Experiment
Compare BAP, TAP, and DAP with the well known Priority
Ceiling Protocol (PCP), Rate Monotonic Scheduling
algorithm (RMS), and Abort Ceiling Protocol (ACP).
49
50
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
51
0.04
0.04
0.03
0.03
Miss Ratio
Miss Ratio
Simulation Results
0.02
0.01
0.02
0.01
0
40
45
50
55
60
65
70
75
80
85
90
95
40
PCP
DAP
BAP
ACP
45
50
55
60
65
70
75
80
85
90
95
PCP
BAP
T AP
DAP
ACP
RMS
Fig 5: T op 1/4 T ransactions, DB size = 50
52
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
0.04
0.03
0.03
Miss Ratio
0.04
0.02
0.01
0.02
0.01
0
40
45
50
55
60
65
70
75
System Load (%)
80
85
90
95
40
45
50
55
60
65
70
75
80
85
90
95
BAP
ACP
T AP
RMS
PCP
BAP
T AP
DAP
ACP
RMS
Fig 7: T op 1/4 T ransactions, DB size = 150
53
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
Simulation Results
0.04
0.25
0.2
Miss Ratio
0.03
Miss Ratio
Miss Ratio
Simulation Results
0.02
0.15
0.1
0.01
0.05
0
40
45
50
55
60
65
70
75
80
85
90
95
40
BAP
ACP
T AP
RMS
45
50
55
60
65
70
75
System Load (%)
80
85
90
PCP
BAP
T AP
DAP
ACP
RMS
Fig 9: T he Whole T ransaction Set, DB siz = 100
54
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
95
Broadcast Commit
Alternation of Serializability
55
@ all rights preserved for Tei-Wei Kuo, National Taiwan University
An timestamp-based algorithm:
The system maintains a valid interval (x,y) for each transaction to assign the transaction a
timestamp at its commit time.
A read timestamp and a write timestamp for each data item which are the latest timestamps of
committed transactions that have read and updated it (updates done at commit times).
Updating of a data item at the commit time of a transaction is effective if the timestamp of the
transaction is larger than the write timestamp of the data item; otherwise, the write timestamp is
not changed and the update is simply ignored.
Example B.1:
x1(r=40,w=3), x2(r=2,w=60), timestamp(T1)=25, ReadSet(T1)= {x1}, WriteSet(T1)={x1,x2,x3}
After T1 commits, x1(r=40,w=25), x2(r=2,w=60), x1 is updated, x2 remains the same.
Remark: The serializability order of transactions scheduled by pessimistic CC is often determined at lock request times.
58
33
T reads X
49
56
of each update.
85
90
of each read.
Y. Lin and S.H. Son, Concurrency control in Real-Time Databases by Dynamically Adjustment of Serializability Order, IEEE Real-Time Systems Symposium, 1990, pp. 104-112.
62