TDD: Research Topics in Distributed Databases
TDD: Research Topics in Distributed Databases
TDD: Research Topics in Distributed Databases
Distributed Databases
Distributed database
Distributed query processing: joins and non-join queries
Updating distributed data
TDD (LN 3)
Distributed databases
Data is stored in several sites (nodes), geographically or
Data centers
What do we get?
Architectures
TDD (LN 3)
DBMS
DB
local schema
network DBMS
TDDDB
(LN 3)
local schema
network
DBMS
DB
Architectures
query answer
client
client
client-server
server
server
server
TDD (LN 3)
Architectures
Collaborating server: query can span several servers
query answer
server
server
server
collaboratingserver
Middleware:
TDD (LN 3)
Warehouse architecture
client applications
data warehouse
integrator
monitor/wrapper
monitor/wrapper
RDB
OODB
TDD (LN 3)
monitor/wrapper
XML
7
Monitor/wrapper
A monitor/wrapper for each data source
translation: translate an information source into a common
integrating model
change detection: detect changes to the underlying data source
Integrator
Receive change notifications from the wrapper/monitors and reflect
the changes in the data warehouse.
Typically a rule-based engine:
merging information (data fusion)
handling references
Data cleaning:
TDD (LN 3)
information
when clients require high query performance but not necessarily
historical information
Examples:
scientific data
historical enterprise data
caching frequently requested information
TDD (LN 3)
10
11
Mediator
wrapper
wrapper
RDB
OODB
TDD (LN 3)
wrapper
XML
12
13
14
R2
R3
R2
TDD (LN 3)
Site 2
15
name
city
001
joe
NYC
002
mary
NYC
003
grace
EDI
fragmentation: determined by
local ownership
query answer
global schema
local schema
NYC
DBMS
DB
local schema
network DBMS
TDDDB
(LN 3)
local schema
network
EDI
DBMS
DB
16
Transparency, independence
Distributed data transparency (independence):
TDD (LN 3)
17
TDD (LN 3)
18
decomposition
global schema
local schema
local schema
local schema
sub-query
sub-query
sub-query
network
DBMS network DBMS
DBMS
DB
TDDDB
(LN 3)
DB
19
Non-join queries
Schema: account(acc-num, branch-name, balance)
Query Q: select * from account where branch-name = `EDI
Storage: database DB is horizontally fragmented, based on
TDD (LN 3)
20
R1
R2
R3
where Ri is at site i, S0 is the site where the query is issued
Option 1: send copies of R1, R2, R3 to S0 and compute the
joins at S0
Option 2:
Send R1 to S2, compute temp1 R1
R2 at S2
Send temp1 to S3, compute temp2 R3
temp1 at S3
Send temp2 to S0
Decision on strategies:
The volume of data shipped
The cost of transmitting a block
Relative speed of processing at each site
TDD (LN 3)
21
R1
Compute temp1
Effectiveness
If sufficiently small fraction of the relation of R2 contributes to
the join
Additional computation cost may be higher than the savings in
communication costs
TDD (LN 3)
22
(R1 R2) R1
exploring parallelism
Consider R1
R2
R3
temp1 R1
temp2 R3
result temp1
temp2 -- pipelining
Question: R1
R3, using
R2
parallel
Pipelined parallelism
Semi-join
both
TDD (LN 3)
24
Two-step optimization
At compile time, generate a query plan along the same lines
as centralized DBMS
Every time before the query is executed, transform the plan and
carry out site selection (determine where the operators are to be
executed) dynamic, just site selection
TDD (LN 3)
25
26
TDD (LN 3)
27
Local transaction
Global transaction
Replication: multiple copies of the same data -- consistency
query answer
global schema
updates
local schema
local schema
DBMS
network DBMS
DB
propagate DB
TDD (LN 3)
local schema
network
DBMS
DB
28
System structure
Local transaction manager: either local transaction or part of a
global transaction
Maintain a log for recovery
Concurrency control for transactions at the site
Transaction coordinator (not in centralized DBMS)
Start the execution of a transaction
Break a transaction into a number of sub-transactions and
distribute them to the appropriate sites
Coordinate the termination of the transaction
Commit at all sites
Abort at all sites
TDD (LN 3)
29
P1
(1) <prepare T>
C
(2) <ready T>
log
P2
<ready T>
prepare T
commit T
abort T
log
if all
responses
(2)
T>
are<abort
<ready>
if one of the
responses is
<abort>
P3
TDD (LN 3)
<no T>
log
30
P1
(3) <commit T>
C
(4) <ack T>
log
P2
<ready T>
<commit T>
prepare T
commit T
complete T
P3
<ready T>
log
<commit T>
TDD (LN 3)
log
31
Comments on 2PC
Two rounds of communication: both initiated at the coordinator
Voting
Terminating
Any site can decide to abort a transaction
Every message reflects a decision by the sender;
The decision is recorded in the log to ensure the decision
survives any failure: transaction id
The log at each participating site: the id of the coordinator
The log at the coordinator: ids of the participating sites
TDD (LN 3)
32
Concurrency control
Single local manager: at a chosen site
D at site j
Send request to the lock manager at site j
Request is either granted or delayed
Deadlock handling is hard
Major complication: replicated data
TDD (LN 3)
33
replication
Synchronous replication: all copies must be updated before the
transaction commits
data distribution transparent, consistent
expensive
Asynchronous replication: copies are periodically updated
Allow modifying transaction to commit before all copies have
been changed
users are aware of data distribution, consistency issues
Cheaper: current products follow this approach
Peer-to-peer replication (master copies)
Primary site replication (only the primary is updateable)
TDD (LN 3)
34
Synchronous replication
Majority approach -- voting: data item D replicated at n sites
TDD (LN 3)
35
TDD (LN 3)
36
TDD (LN 3)
37
38
Asynchronous replication
Primary site: choose exactly one copy, residing at a primary site
TDD (LN 3)
39
TDD (LN 3)
40
Nodes: transactions
Edges: T1 T2 if T1 requests a resource being held by T2
Local wait-for graph:
T2
T2
T5
T3
Site 1
T3
T4
TDD (LN 3)
Site 2
T1
T2
T5
T3
T4
global
41
False cycles
Due to communication delay
Site 1: local wait-for graph has T1 T2
T2 releases the resource deletion of the edge
Site 2: T2 requests the resource again addition of T2 T1
Cycle if insert T2 T1 arrives before removal of T1 T2
Centralized deadlock detection deadlock detection coordinator
Constructs/maintains global wait-for graph
Detect cycles
If it finds a cycle, chose a victim to be rolled back
Distributed deadlock manager? More expensive
T1
Site 1
T2
T1
T2
TDD (LN 3)
Site 2
T1
T2
global
42
43