SlideShare a Scribd company logo
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/1
Outline
• Introduction
• Background
• Distributed Database Design
• Database Integration
• Semantic Data Control
• Distributed Query Processing
• Distributed Transaction Management
• Data Replication
• Parallel Database Systems
• Distributed Object DBMS
• Peer-to-Peer Data Management
➡ P2P infrastructure
➡ Schema mapping
➡ Querying over P2P systems
➡ Replica management in P2P systems
• Web Data Management
• Current Issues
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/2
Motivations
• P2P systems
➡Each peer can have same functionality
➡Decentralized control, large scale
➡Low-level, simple services
✦ File sharing, computation sharing, com. sharing
• Traditional distributed DBMSs
➡High-level data management services
✦ queries, transactions, consistency, security, etc.
➡Centralized control, limited scale
• P2P + distributed database
➡Why? How?
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/3
Why High-level P2P Data
Sharing?
• Professional community example
➡ Medical doctors in a hospital may want to share (some of) their patient data
for an epidemiological study
➡ They have their own, independent patient descriptions
➡ They want to ask queries such as “age and weight of male patients diagnosed
with disease X …” over their own descriptions
➡ They don’t want to create a database and set a centralized server
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/4
Problem Definition
• P2P system
➡ No centralized control, very large scale
➡ Very dynamic: peers can join and leave the network at any time
➡ Peers can be autonomous and unreliable
• Techniques designed for distributed data management need be extended
➡ Too static, need to be decentralized, dynamic and self-adaptive
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/5
Peer Reference Architecture
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/6
Potential Benefits of P2P
Systems
• Scale up to very large numbers of peers
• Dynamic self-organization
• Load balancing
• Parallel processing
• High availability through massive replication
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/7
P2P vs Traditional Distributed
DBMS
P2P Distributed
DBMS
Joining the
network
Upon peer’s
initiative
Controled by DBA
Queries No schema,
key-word based
Global schema,
static optimization
Query answers Partial Complete
Content location Using neighbors
or DHT
Using directory
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/8
Requirements for P2P Data
Management
• Autonomy of peers
➡ Peers should be able to join/leave at any time, control their data with respect
to other (trusted) peers
• Query expressiveness
➡ Key-lookup, key-word search, SQL-like
• Efficiency
➡ Efficient use of bandwidth, computing power, storage
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/9
Requirements for P2P Data
Management (cont’d)
• Quality of service (QoS)
➡ User-perceived efficiency: completeness of results, response time, data
consistency, …
• Fault-tolerance
➡ Efficiency and QoS despite failures
• Security
➡ Data access control in the context of very open systems
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/10
P2P Network Topologies
• Pure P2P systems
➡ Unstructured systems
✦ e.g. Napster, Gnutella, Freenet, Kazaa, BitTorrent
➡ Structured systems (DHT)
✦ e.g. LH* (the earliest form of DHT), CAN, CHORD, Tapestry, Freepastry, Pgrid,
Baton
• Super-peer (hybrid) systems
➡ e.g. Edutela, JXTA
• Two issues
➡ Indexing data
➡ Searching data
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/11
P2P Unstructured Network
• High autonomy (peer only needs to know neighbor to
login)
• Searching by
➡ flooding the network: general, may be inefficient
➡ Gossiping between selected peers: robust, efficient
• High-fault tolerance with replication
p2p
data
peer 1
p2p
data
peer 2
p2p
data
peer 3
p2p
data
peer 4
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/12
Search over Centralized Index
1. A peer asks the
central index
manager for resource
2. The response
identifies the peer
with the resource
3. The peer is asked for
the resource
4. It is transferred
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/13
Search over Distributed Index
1. A peer sends the
request for
resource to all its
neighbors
2. Each neighbor
propagates to its
neighbors if it
doesn’t have the
resource
3. The peer who has
the resource
responds by
sending the
resource
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/14
P2P Structured Network
• Simple API with put(key, data) and get(key)
➡ The key (an object id) is hashed to generate a peer id, which stores the
corresponding data
• Efficient exact-match search
➡ O(log n) for put(key, data), get(key)
• Limited autonomy since a peer is responsible for a range of keys
p2p
d(k1)
peer 1
p2p
d(k2)
peer 2
p2p
d(k3)
peer 3
p2p
d(k4)
peer 4
h(k1)= p1 h(k2)= p2 h(k3)= p3 h(k4)= p4
Distributed Hash Table (DHT)
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/15
Super-peer Network
• Super-peers can perform complex functions (meta-data
management, indexing, access control, etc.)
➡ Efficiency and QoS
➡ Restricted autonomy
➡ SP = single point of failure use several super-peers
p2sp
data
peer 1
p2sp
data
peer 2
p2sp
data
peer 3
p2sp
data
peer 4
sp2sp
sp2p
sp2sp
sp2p
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/16
Search over a Super-peer
System
1. A peer sends the
request for resource to
all its super-peer
2. The super-peer sends
the request to other
super-peers if necessary
3. The super-peer one of
whose peers has the
resource responds by
indicating that peer
4. The super-peer notifies
the original peer
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/17
P2P Systems Comparison
Requirements Unstructured DHT Super-peer
Autonomy high low avg
Query exp. high low high
Efficiency low high high
QoS low high high
Fault-tolerance high high low
Security low low high
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/18
P2P Schema Mapping
• Problem: support decentralized schema mapping so that a query expressed
on one peer’s schema can be reformulated to a query on another peer’s
schema
• Main approaches
➡ Pairwise schema mapping
➡ Mapping based on machine learning
➡ Common agreement mapping
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/19
Pairwise Schema Mapping
• Each user defines the
mapping between the local
schema and the schema of
any other peer that contains
data that are of interest
• Relying on the transitivity
of the defined mappings,
the system tries to extract
mappings between schemas
that have no defined
mapping
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/20
• This approach is generally used when the shared data are defined based
on ontologies and taxonomies as proposed for the semantic web
• It uses machine learning techniques to automatically extract the mappings
between the shared schemas
• The extracted mappings are stored over the network, in order to be used
for processing future queries
Mapping Based on Machine
Learning
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/21
Common Agreement Mapping
• Some (cooperating)
peers must agree on a
Common Schema
Description (CSD)
• Given a CSD, a peer
schema can be specified
using views
➡ Similar to the LAV
approach
• When a peer decides to
share data, it needs to
map its local schema to
the CSD
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/22
Querying over P2P Systems
• P2P networks provide basic query routing
➡ Sufficient for simple, exact-match queries, e.g. with a DHT
• Supporting more complex queries, particularly in DHTs, is difficult
• Main types of complex queries
➡ Top-k queries
➡ Join queries
➡ Range queries
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/23
Top-k Query
• Returns only k of the most relevant answers, ordered by relevance
➡ Like for a search engine
• Scoring function (sf) determines the relevance (score) of answers to the
query
• Example
SELECT *
FROM Patient P
WHERE (P.disease = “diabetes”) AND
(P.height < 170) AND (P.weight > 70)
ORDER BY sf(height, weight)
STOP AFTER 10
➡ Example of sf: weight − (height -100)
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/24
General Model for Top-k Queries
• Suppose we have:
➡ n data items
✦ items can be document, tuples, etc.
➡ m lists of n data items such that
✦ Each data item has
✓ a local score in each list
✓ an overall score computed based on its local scores in all lists using a given scoring function
✦ Each list
✓ contains all n data items (or item ids)
✓ is sorted in decreasing order of the local scores
• The objective is:
➡ Given a scoring function, find the k data items whose overall scores are the highest
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/25
Execution Cost of Top-k Queries
• Two modes of access to a sorted list
➡ Sorted (sequential) access
✦ Starts with the first data item, then accesses each next item
➡ Random access
✦ Looks up a given data item in the list by its identifier (e.g. TID)
• Given a top-k algorithm A and a database D (i.e. set of sorted lists), the cost
of executing A over D is:
➡ Cost(A, D) = (#sorted-access * sorted-access-cost) + (#random-access *
random-access-cost)
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/26
Basic Top-k Algorithms
• Fagin’s Algorithm (FA)
➡ General model of top-k queries using sorted lists
➡ Simple algorithm
✦ Do sorted access in parallel to the lists until at least k data items have been seen in all
lists
• Threshold Algorithm (TA)
➡ Proposed independently by several groups
➡ Efficient algorithm over sorted lists
➡ The basis for many TA-style distributed algorithms
✦ Mainly for DHTs
✦ Algorithms for unstructured or super-peer simpler
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/27
TA
• Similar to FA in doing sorted access to the lists
➡ But different stopping condition
• Unlike FA, no need to wait until the lists give k items
➡ Once an item has been seen from a sorted access, get all its scores through
random access
• But how do we know that the scores of seen items are higher than those of unseen
items?
➡ Use a threshold (T) to predict maximum possible score of unseen items
✦ based on the last scores seen in the lists under sorted access
➡ Then stop when there are at least k data items whose overall score ≥ T
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/28
TA Example
• Assume sf( ) = s1 + s2 + s3, k = 3,
Y: {top seen items with overall scores}
• At position 1
➡ Look up the local scores of items d1, d2 and d3 in other
lists using random access and compute their overall
scores (which are 65, 63 and 70, respectively)
➡ Y = {(d1,70) (d2,65) (d3,63)}, T = 30 + 28 + 30 = 88
• Then
➡ At position 2, Y = {(d3,70) (d4,70) (d5,65)}, T = 84
➡ At position 3, Y = {(d3,71) (d5,70) (d8,70)}, T = 80
➡ At position 4, Y = same, T = 75
➡ At position 5, Y = same, T = 72
➡ At position 6, Y = same, T = 63
✦ which is less than the overall score of the three data items in
Y. Thus, TA stops
• Note that the contents of Y at position 6 is
exactly the same as at position 3
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/29
Improvement over TA: BPA
• Best Position Algorithm
• Main idea: keep track of the positions (and scores) of the items seen under sorted
or random access
➡ Enables BPA to stop as soon as possible
✦ In the previous example, BPA stops at position 3
• Best position = the greatest seen position in a list such that any position
before it is also seen
➡ Thus, we are sure that all positions between 1 and best position have been seen
• Stopping condition
➡ Based on best positions overall score, i.e. the overall score computed based on
the best positions in all lists
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/30
Top-k Query Processing in DHTs
• Given
➡ A DHT network
➡ T : a set of tuples which are stored in the DHT
➡ Q : a top-k query
➡ sf : a scoring function
• Goal
➡ Retrieve efficiently the k tuples stored in the DHT whose scores are the
highest according to Q and sf
➡ While avoiding centralized data storage
• DHTop algorithm
➡ TA style
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/31
Data Storage Mechanism
• Two complementary methods for storing tuples in the DHT
➡ Tuple storage: each tuple of a relation is stored in the DHT using its tuple’s
identifier (e.g. primary key)
✦ Allows to retrieve tuples using their identifier
➡ Attribute storage: the values of some attributes of a tuple are stored
individually in the DHT
✦ Acts as secondary indices
✦ Good support for exact match queries
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/32
Tuple Storage Method
• Let
➡ R (a1, a2, …, am) be a relation
➡ t 〈v1, v2, …, vm〉 be a tuple of R
➡ v1 be the primary key of tuple t
➡ h : a hash function that hashes its inputs into a DHT key
• To store tuple t in the DHT, a peer does as follows:
➡ ts_key = h(R, v1);
➡ put(ts_key, v1, v2, …, vm );
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/33
Attribute-value storage
• Domain partitioning
➡ Let Da be the domain of an attribute a
➡ We partition Da into n nonempty sub-domains d1, d2, ..., dn
➡ Example:
✦ Attribute “weight”, with domain [0..200] in kilograms, can be partitioned into
n=40 sub-domains [0..5), [5..10), …, [190..195), [195..200]
• Exploitation by peers
➡ All peers know the sub-domains of each attribute
➡ Thus, each peer can locally execute the following function:
✦ sd(a, v) : returns the sub-domain of attribute a to which value v belongs
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/34
Attribute-Value Storage (cont’d)
• Let
➡ R(a1, a2, …, am) be a relation
➡ t v1, v2, …, vm be a tuple of R
➡ ts_keyt : the key used for storing tuple t in the DHT, i.e. h(R, v1);
• For storing the value v2 of attribute a2 in the DHT :
➡ let di be the sub-domain to which v2 belongs, i.e. di = sd(a2, v2);
avs_key h(R, a2, di);
put(avs_key, v2 , ts_keyt );
• Two important features:
1. After retrieving an attribute value, we are able to retrieve its entire tuple
2. The values that are “relatively close” are stored at the same peer
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/35
DHTop
• Two phases, executed by the peer where Q is originated
• Phase 1: Prepare ordered lists of attributes’ sub-domains
➡ For each scoring attribute a :
✦ Step 1: create a list of a’s sub-domains, denoted by La
✦ Step 2: remove useless sub-domains by considering Q’s conditions
✓ E.g. condition a = c , remove all sub-domains except sub-domain of c
✦ Step 3: sort La according to the positive impact of its sub-domains on the
scoring function
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/36
DHTop (cont’d)
• Phase 2: Continuously retrieve attribute values and their tuples until finding
the k top tuples
➡ For each scoring attribute a do in parallel
i=1
Repeat
1. Ask the peer p that maintains attribute values for La[i] (i.e. i-th sub-
domain in the list) to return its attribute values in order of their positive
impact on the scoring function
2. After receiving each attribute value v
o Retrieve the entire tuple
o Check End-Condition: are there at least k tuples (among the
retrieved tuples) whose scores are greater than the threshold?
o If end-condition holds, then exit
3. If all values maintained by p are received then
o i = i + 1
Until (end-condition holds) or (i ≥ number of a’s sub-domains)
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/37
DHTop Threshold
• Let a1, a2, ..., am be the scoring attributes, and v1, v2, ..., vm be the last values
retrieved for them
• Let f be the scoring function
• The threshold is = f(v1, v2, …, vm)
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/38
Top-k Query Processing in
Unstructured Systems
• Fully Decentralized (FD) algorithm
➡ Fully decentralized query execution
➡ No centralized information
➡ Considers dynamicity of peers
➡ Simple, efficient and fault-tolerant
✦ Many optimizations possible
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/39
FD Algorithm Overview
1. Query Forward
➡ If TTL > 0, send Q to your neighbors
2. Local query execution
➡ Extract the k local top scores
3. Wait
➡ Wait to receive from the neighbors their k top scores
➡ The wait time is based on the received TTL, network parameters and peer’s local
processing parameters
4. Merge-and-Backward
➡ Extract k top scores from the local and received scores
➡ Send the k top scores to your parent
5. Data retrieval (at the query originator)
➡ Retrieve the overall top-k data using the final top scores
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/40
State Transition Diagram
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/41
FD Optimizations
• What if a peer receives a score-list after its wait time has expired?
➡ Urgent Score-list: a mechanism to backward a score-list to another peer still in
the wait phase
• What if the parent of a peer p leave the system?
➡ If p has a neighbor that is not p’s child, the score-list can be sent to it as an
urgent score-list
➡ If p has not such a neighbor, it can send its merged score-list directly to the
query originator
• Return results ASAP
➡ Without waiting for the entire result set
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/42
Join Query Processing in DHTs
• A DHT relies on hashing to store and locate data
➡ Basis for parallel hash join algorithms
• Basic solution in the context of the PIER P2P system
➡ Let us call it PIERjoin
➡ Assume that the joined relations and the result relations have a home which
are the peers that store horizontal fragments of the relation
✦ Recall def. of home from Chapter 8
➡ Make use of the put method for distributing tuples onto a set of peers based
on their join attribute so that tuples with the same join attribute values are
stored at the same peers
➡ Then apply the probe/join phase
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/43
PIERjoin Algorithm
1. Multicast phase
➡ The query originator peer multicasts Q to all peers that store tuples of the
join relations R and S, i.e., their homes.
2. Hash phase
➡ Each peer that receives Q scans its local relation, searching for the tuples
that satisfy the select predicate (if any)
➡ Then, it sends the selected tuples to the home of the result relation, using
put operations
➡ The DHT key used in the put operation uses the home of the result
relation and the join attribute
3. Probe/join phase
➡ Each peer in the home of the result relation, upon receiving a new
tuple, inserts it in the corresponding hash table, probes the opposite hash
table to find matching tuples and constructs the result joined tuples
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/44
Range Query Processing
• Range query
➡ WHERE clause of the form “attribute A in range [a; b]”
• Difficult to support in structured P2P systems, in particular, DHTs
➡ Hashing tends to destroy the ordering of data that is useful in finding ranges
quickly
• Two main approaches for supporting range queries in structured P2P
systems
➡ Extend a DHT with proximity or order-preserving properties
✦ Problem: data skew that can result in peers with unbalanced ranges, which hurts
load balancing
➡ Maintain the key ordering with a tree-based structure
✦ Better at maintaining balanced ranges of keys
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/45
BATON
• BATON (BAlanced Tree Overlay Network)
• Organizes peers as a balanced binary tree
➡ Each node of the tree is maintained by a peer
➡ The position of a node is determined by a (level, number) tuple, with level
starting from 0 at the root, number starting from 1 at the root and sequentially
assigned using in-order traversal
➡ Each tree node stores links to its parent, children, adjacent nodes and selected
neighbor nodes that are nodes at the same level
➡ Two routing tables: a left routing table and a right routing table store links to
the selected neighbor nodes
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/46
BATON Structure-tree Index
• Each node (or peer) is assigned a range of values
➡ Maintained at the routing table of each link
➡ Required to be to the right of the range managed by its left subtree and less than
the range managed by its right subtree
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/47
Range Query Processing in
BATON
Input: Q, a range query in the form [a,b]
Output: T: result relation
1. Search for the peer storing the lower bound of the range
At query originator node do
find peer p that holds value a
send Q to p
2. A peer p that receives Q (from query originator or its left adjacent
peer) searches for local tuples and sends Q to its right adjacent node
At each peer p that receives Q
Tp = Range(p) [a,b]
send Tp to query originator
If (Range(RighAdjacent(p)) [a,b]) not empty
send Q to right adjacent peer of p
• With X nodes covering the range, Q is answered in O(log n + X) steps
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/48
Example of Range Query
Execution
• Consider Q with range [7; 45] issued
at node 7
• First, execute an exact match query
looking for a node containing the
lower bound of the range (see dashed
line)
• Since the lower bound is in node 4’s
range, check locally for tuples
belonging to the range and forward Q
to its adjacent right node (node 9)
• Node 9 checks for local tuples
belonging to the range and forwards
Q to node 2
• Nodes 10, 5, 1 and 6 receive Q, check
for local tuples and contact their
respective right adjacent node until
the node containing the upper bound
of the range is reached
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/49
Replica Consistency
• To increase data availability and access performance, P2P systems
replicate data, however, with very different levels of replica
consistency
➡ The earlier, simple P2P systems such as Gnutella and Kazaa deal only
with static data (e.g., music files) and replication is “passive” as it occurs
naturally as peers request and copy files from one another
(basically, caching data)
• In more advanced P2P systems where replicas can be updated, there is
a need for proper replica management techniques
• Replica consistency in DHTs
➡ Basic support - Tapestry
➡ Replica reconciliation - OceanStore
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/50
Tapestry
• Decentralized object location and routing on top of a structured overlay
• Routes messages to logical end-points (i.e., not associated with physical
location), such as nodes or object replicas.
➡ This enables message delivery to mobile or replicated endpoints in the
presence of network instability
• Location and routing
➡ Let O be an object identified by id(O), the insertion of O involves two nodes:
the server node (noted ns) that holds O and the root node (noted nr) that holds
a mapping in the form (id(O); ns) indicating that the object identified by id(O)
is stored at node ns
➡ The root node is dynamically determined by a globally consistent
deterministic algorithm
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/51
Object Publishing in Tapestry
• When O is inserted into ns, ns
publishes id(O) at its root node by
routing a message from ns to nr
containing the mapping (id(O); ns)
• This mapping is stored at all nodes
along the message path
• During a location query (e.g.,
“id(O)?”, the message that looks for
id(O) is initially routed towards nr,
but it may be stopped before
reaching it once a node containing
the mapping (id(O); ns) is found
• For routing a message to id(O)’s
root, each node forwards this
message to its neighbor whose
logical identifier is the most similar
to id(O)
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/52
Replica Management in Tapestry
• Each node represents a peer and contains
the peer’s logical identifier in hexadecimal
format
• Two replicas O1 and O2 of object O (e.g., a
book file) are inserted into distinct peers
(O1 at peer 4228 and O2 at peer AA93). The
identifier of O1 is equal to that of O2 (i.e.,
4378)
• When O1 is inserted into its server node
(peer 4228), the mapping (4378; 4228) is
routed from peer 4228 to peer 4377 (the
root node for O1’s identifier)
• As the message approaches the root node,
the object and the node identifiers become
increasingly similar
• In addition, the mapping (4378; 4228) is
stored at all peers along the message path
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/53
OceanStore
• OceanStore is a data management system designed to provide continuous
access to persistent information
• Relies on Tapestry and assumes untrusted powerful servers connected by
high-speed links
• To improve performance, data are allowed to be cached
anywhere, anytime
• Allows concurrent updates on replicated objects; it relies on reconciliation
to assure data consistency
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/54
Reconciliation in OceanStore
• Ri and ri denote, respectively, a primary and a
secondary copy of object R
• Nodes n1 and n2 are concurrently updating R
as follows
➡ Nodes that hold primary copies of R, called the
master group of R, are responsible for ordering
updates
➡ (a) n1 and n2 perform tentative updates on their
local secondary replicas and send these updates
to the master group of R as well as to other
random secondary replicas
➡ (b) The tentative updates are ordered by the
master group based on timestamps assigned by
n1 and n2, and epidemically propagated among
secondary replicas
➡ (c) Once the master group obtains an agreement,
the result of updates is multicast to secondary
replicas
Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/55
Conclusion
• Advanced P2P applications will need high-level data management services
• Various P2P networks will improve
➡ Network-independence crucial to exploit and combine them
• Many technical issues
➡ Decentralized schema management, complex query processing, transaction
support and replication, and data privacy
• Important to characterize applications that can most benefit from P2P with
respect to other distributed architectures

More Related Content

What's hot (20)

PPTX
Replication in Distributed Database
Abhilasha Lahigude
 
PPT
20. Parallel Databases in DBMS
koolkampus
 
PPTX
Parallel databases
Aniruddha Patil
 
PPSX
Parallel Database
VESIT/University of Mumbai
 
PPTX
Load Balancing in Parallel and Distributed Database
Md. Shamsur Rahim
 
PPTX
Transaction conccurency
Esraa Farrag
 
PPTX
Database , 1 Introduction
Ali Usman
 
PPTX
SHADOW PAGING and BUFFER MANAGEMENT
ramya marichamy
 
PPTX
1 introduction ddbms
amna izzat
 
PPTX
Page replacement
Davin Abraham
 
PPTX
141060753008 3715302
ITM Universe - Vadodara
 
PDF
Composing and scaling data platforms
Sigmoid
 
PDF
Composing and Scaling Data Platforms-2015
Rahul Kumar
 
PPTX
NoSQL Evolution
Abdul Manaf
 
PPTX
IMC Summit 2016 Breakout - Pandurang Naik - Demystifying In-Memory Data Grid,...
In-Memory Computing Summit
 
PPTX
Virtual memory and page replacement algorithm
Muhammad Mansoor Ul Haq
 
PPT
Dbms by jeet goyal
jeet1991
 
PPTX
Maximizing performance via tuning and optimization
MariaDB plc
 
PDF
Aerospike Hybrid Memory Architecture
Aerospike, Inc.
 
ZIP
Practical MySQL
Indus Khaitan
 
Replication in Distributed Database
Abhilasha Lahigude
 
20. Parallel Databases in DBMS
koolkampus
 
Parallel databases
Aniruddha Patil
 
Parallel Database
VESIT/University of Mumbai
 
Load Balancing in Parallel and Distributed Database
Md. Shamsur Rahim
 
Transaction conccurency
Esraa Farrag
 
Database , 1 Introduction
Ali Usman
 
SHADOW PAGING and BUFFER MANAGEMENT
ramya marichamy
 
1 introduction ddbms
amna izzat
 
Page replacement
Davin Abraham
 
141060753008 3715302
ITM Universe - Vadodara
 
Composing and scaling data platforms
Sigmoid
 
Composing and Scaling Data Platforms-2015
Rahul Kumar
 
NoSQL Evolution
Abdul Manaf
 
IMC Summit 2016 Breakout - Pandurang Naik - Demystifying In-Memory Data Grid,...
In-Memory Computing Summit
 
Virtual memory and page replacement algorithm
Muhammad Mansoor Ul Haq
 
Dbms by jeet goyal
jeet1991
 
Maximizing performance via tuning and optimization
MariaDB plc
 
Aerospike Hybrid Memory Architecture
Aerospike, Inc.
 
Practical MySQL
Indus Khaitan
 

Viewers also liked (20)

PPTX
Database , 13 Replication
Ali Usman
 
PPTX
Database ,2 Background
Ali Usman
 
PPTX
Database , 8 Query Optimization
Ali Usman
 
PDF
Ethernet Technology
Ali Usman
 
PPTX
Hank Iving Media Plan
confar90
 
PDF
Virgen de Chiquinquirá en Colombia
Maria Daud
 
PDF
Anwar e-sabiri(complete)
Ali Usman
 
PDF
Coyaima ie. juan xxiii manual de convivencia
sebasecret
 
PDF
Mariquita iet francisco nuñez pedrozo manual convivencia antiguo
sebasecret
 
PPTX
College Students
confar90
 
PPT
Prezentacja.1
magda260490
 
PPTX
PL/pgSQL - An Introduction on Using Imperative Programming in PostgreSQL
Reactive.IO
 
PPT
Gsm (Part 3)
Ali Usman
 
PDF
MySQL InnoDB 源码实现分析(一)
frogd
 
PPTX
Database , 12 Reliability
Ali Usman
 
PPTX
Postgres MVCC - A Developer Centric View of Multi Version Concurrency Control
Reactive.IO
 
PDF
InnoDB Internal
mysqlops
 
PPTX
Database ,7 query localization
Ali Usman
 
PPTX
Database, 3 Distribution Design
Ali Usman
 
Database , 13 Replication
Ali Usman
 
Database ,2 Background
Ali Usman
 
Database , 8 Query Optimization
Ali Usman
 
Ethernet Technology
Ali Usman
 
Hank Iving Media Plan
confar90
 
Virgen de Chiquinquirá en Colombia
Maria Daud
 
Anwar e-sabiri(complete)
Ali Usman
 
Coyaima ie. juan xxiii manual de convivencia
sebasecret
 
Mariquita iet francisco nuñez pedrozo manual convivencia antiguo
sebasecret
 
College Students
confar90
 
Prezentacja.1
magda260490
 
PL/pgSQL - An Introduction on Using Imperative Programming in PostgreSQL
Reactive.IO
 
Gsm (Part 3)
Ali Usman
 
MySQL InnoDB 源码实现分析(一)
frogd
 
Database , 12 Reliability
Ali Usman
 
Postgres MVCC - A Developer Centric View of Multi Version Concurrency Control
Reactive.IO
 
InnoDB Internal
mysqlops
 
Database ,7 query localization
Ali Usman
 
Database, 3 Distribution Design
Ali Usman
 
Ad

Similar to Database ,16 P2P (20)

PPTX
AUERY.pptxHDSOILDKCJSIDVCBIDCSDCJNSOIDCNSOD
AhmadSajjad34
 
PPTX
1 introduction DDBS
naimanighat
 
PPTX
DBMS Notes for BSC Students for all batch
sudhanadar606
 
PPTX
1 introduction
Amrit Kaur
 
PDF
6-Query_Intro (5).pdf
JaveriaShoaib4
 
PDF
Module: Mutable Content in IPFS
Ioannis Psaras
 
PPT
Lec07 multiprocessor schaduling chap.ppt
naghamsalimmohammed
 
PPTX
Hadoop
RittikaBaksi
 
PDF
Module: Content Routing in IPFS
Ioannis Psaras
 
PPTX
Got documents Code Mash Revision
Maggie Pint
 
PDF
Meta scale kognitio hadoop webinar
Michael Hiskey
 
PPTX
SQL In/On/Around Hadoop
DataWorks Summit
 
PDF
Meta scale kognitio hadoop webinar
Kognitio
 
PPTX
Got documents - The Raven Bouns Edition
Maggie Pint
 
PPTX
Cloud Computing 1.3.pptx
kalavathisugan
 
PDF
Константин Швачко, Yahoo!, - Scaling Storage and Computation with Hadoop
Media Gorod
 
PPTX
Hdfs
dash-javad
 
PPT
Hadoop
Mallikarjuna G D
 
PPTX
Got documents?
Maggie Pint
 
PPT
HDFS_architecture.ppt
vijayapraba1
 
AUERY.pptxHDSOILDKCJSIDVCBIDCSDCJNSOIDCNSOD
AhmadSajjad34
 
1 introduction DDBS
naimanighat
 
DBMS Notes for BSC Students for all batch
sudhanadar606
 
1 introduction
Amrit Kaur
 
6-Query_Intro (5).pdf
JaveriaShoaib4
 
Module: Mutable Content in IPFS
Ioannis Psaras
 
Lec07 multiprocessor schaduling chap.ppt
naghamsalimmohammed
 
Hadoop
RittikaBaksi
 
Module: Content Routing in IPFS
Ioannis Psaras
 
Got documents Code Mash Revision
Maggie Pint
 
Meta scale kognitio hadoop webinar
Michael Hiskey
 
SQL In/On/Around Hadoop
DataWorks Summit
 
Meta scale kognitio hadoop webinar
Kognitio
 
Got documents - The Raven Bouns Edition
Maggie Pint
 
Cloud Computing 1.3.pptx
kalavathisugan
 
Константин Швачко, Yahoo!, - Scaling Storage and Computation with Hadoop
Media Gorod
 
Got documents?
Maggie Pint
 
HDFS_architecture.ppt
vijayapraba1
 
Ad

More from Ali Usman (15)

PPT
Cisco Packet Tracer Overview
Ali Usman
 
PDF
Islamic Arts and Architecture
Ali Usman
 
PPTX
Database ,11 Concurrency Control
Ali Usman
 
DOCX
Processor Specifications
Ali Usman
 
PDF
Fifty Year Of Microprocessor
Ali Usman
 
PDF
Discrete Structures lecture 2
Ali Usman
 
PDF
Discrete Structures. Lecture 1
Ali Usman
 
PDF
Muslim Contributions in Medicine-Geography-Astronomy
Ali Usman
 
PDF
Muslim Contributions in Geography
Ali Usman
 
PDF
Muslim Contributions in Astronomy
Ali Usman
 
DOCX
Processor Specifications
Ali Usman
 
PDF
Ptcl modem (user manual)
Ali Usman
 
PDF
Nimat-ul-ALLAH shah wali
Ali Usman
 
PDF
Muslim Contributions in Mathematics
Ali Usman
 
PDF
Osi protocols
Ali Usman
 
Cisco Packet Tracer Overview
Ali Usman
 
Islamic Arts and Architecture
Ali Usman
 
Database ,11 Concurrency Control
Ali Usman
 
Processor Specifications
Ali Usman
 
Fifty Year Of Microprocessor
Ali Usman
 
Discrete Structures lecture 2
Ali Usman
 
Discrete Structures. Lecture 1
Ali Usman
 
Muslim Contributions in Medicine-Geography-Astronomy
Ali Usman
 
Muslim Contributions in Geography
Ali Usman
 
Muslim Contributions in Astronomy
Ali Usman
 
Processor Specifications
Ali Usman
 
Ptcl modem (user manual)
Ali Usman
 
Nimat-ul-ALLAH shah wali
Ali Usman
 
Muslim Contributions in Mathematics
Ali Usman
 
Osi protocols
Ali Usman
 

Recently uploaded (20)

PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PPTX
Q2 Leading a Tableau User Group - Onboarding
lward7
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Q2 Leading a Tableau User Group - Onboarding
lward7
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Windsurf Meetup Ottawa 2025-07-12 - Planning Mode at Reliza.pdf
Pavel Shukhman
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 

Database ,16 P2P

  • 1. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/1 Outline • Introduction • Background • Distributed Database Design • Database Integration • Semantic Data Control • Distributed Query Processing • Distributed Transaction Management • Data Replication • Parallel Database Systems • Distributed Object DBMS • Peer-to-Peer Data Management ➡ P2P infrastructure ➡ Schema mapping ➡ Querying over P2P systems ➡ Replica management in P2P systems • Web Data Management • Current Issues
  • 2. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/2 Motivations • P2P systems ➡Each peer can have same functionality ➡Decentralized control, large scale ➡Low-level, simple services ✦ File sharing, computation sharing, com. sharing • Traditional distributed DBMSs ➡High-level data management services ✦ queries, transactions, consistency, security, etc. ➡Centralized control, limited scale • P2P + distributed database ➡Why? How?
  • 3. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/3 Why High-level P2P Data Sharing? • Professional community example ➡ Medical doctors in a hospital may want to share (some of) their patient data for an epidemiological study ➡ They have their own, independent patient descriptions ➡ They want to ask queries such as “age and weight of male patients diagnosed with disease X …” over their own descriptions ➡ They don’t want to create a database and set a centralized server
  • 4. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/4 Problem Definition • P2P system ➡ No centralized control, very large scale ➡ Very dynamic: peers can join and leave the network at any time ➡ Peers can be autonomous and unreliable • Techniques designed for distributed data management need be extended ➡ Too static, need to be decentralized, dynamic and self-adaptive
  • 5. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/5 Peer Reference Architecture
  • 6. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/6 Potential Benefits of P2P Systems • Scale up to very large numbers of peers • Dynamic self-organization • Load balancing • Parallel processing • High availability through massive replication
  • 7. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/7 P2P vs Traditional Distributed DBMS P2P Distributed DBMS Joining the network Upon peer’s initiative Controled by DBA Queries No schema, key-word based Global schema, static optimization Query answers Partial Complete Content location Using neighbors or DHT Using directory
  • 8. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/8 Requirements for P2P Data Management • Autonomy of peers ➡ Peers should be able to join/leave at any time, control their data with respect to other (trusted) peers • Query expressiveness ➡ Key-lookup, key-word search, SQL-like • Efficiency ➡ Efficient use of bandwidth, computing power, storage
  • 9. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/9 Requirements for P2P Data Management (cont’d) • Quality of service (QoS) ➡ User-perceived efficiency: completeness of results, response time, data consistency, … • Fault-tolerance ➡ Efficiency and QoS despite failures • Security ➡ Data access control in the context of very open systems
  • 10. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/10 P2P Network Topologies • Pure P2P systems ➡ Unstructured systems ✦ e.g. Napster, Gnutella, Freenet, Kazaa, BitTorrent ➡ Structured systems (DHT) ✦ e.g. LH* (the earliest form of DHT), CAN, CHORD, Tapestry, Freepastry, Pgrid, Baton • Super-peer (hybrid) systems ➡ e.g. Edutela, JXTA • Two issues ➡ Indexing data ➡ Searching data
  • 11. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/11 P2P Unstructured Network • High autonomy (peer only needs to know neighbor to login) • Searching by ➡ flooding the network: general, may be inefficient ➡ Gossiping between selected peers: robust, efficient • High-fault tolerance with replication p2p data peer 1 p2p data peer 2 p2p data peer 3 p2p data peer 4
  • 12. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/12 Search over Centralized Index 1. A peer asks the central index manager for resource 2. The response identifies the peer with the resource 3. The peer is asked for the resource 4. It is transferred
  • 13. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/13 Search over Distributed Index 1. A peer sends the request for resource to all its neighbors 2. Each neighbor propagates to its neighbors if it doesn’t have the resource 3. The peer who has the resource responds by sending the resource
  • 14. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/14 P2P Structured Network • Simple API with put(key, data) and get(key) ➡ The key (an object id) is hashed to generate a peer id, which stores the corresponding data • Efficient exact-match search ➡ O(log n) for put(key, data), get(key) • Limited autonomy since a peer is responsible for a range of keys p2p d(k1) peer 1 p2p d(k2) peer 2 p2p d(k3) peer 3 p2p d(k4) peer 4 h(k1)= p1 h(k2)= p2 h(k3)= p3 h(k4)= p4 Distributed Hash Table (DHT)
  • 15. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/15 Super-peer Network • Super-peers can perform complex functions (meta-data management, indexing, access control, etc.) ➡ Efficiency and QoS ➡ Restricted autonomy ➡ SP = single point of failure use several super-peers p2sp data peer 1 p2sp data peer 2 p2sp data peer 3 p2sp data peer 4 sp2sp sp2p sp2sp sp2p
  • 16. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/16 Search over a Super-peer System 1. A peer sends the request for resource to all its super-peer 2. The super-peer sends the request to other super-peers if necessary 3. The super-peer one of whose peers has the resource responds by indicating that peer 4. The super-peer notifies the original peer
  • 17. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/17 P2P Systems Comparison Requirements Unstructured DHT Super-peer Autonomy high low avg Query exp. high low high Efficiency low high high QoS low high high Fault-tolerance high high low Security low low high
  • 18. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/18 P2P Schema Mapping • Problem: support decentralized schema mapping so that a query expressed on one peer’s schema can be reformulated to a query on another peer’s schema • Main approaches ➡ Pairwise schema mapping ➡ Mapping based on machine learning ➡ Common agreement mapping
  • 19. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/19 Pairwise Schema Mapping • Each user defines the mapping between the local schema and the schema of any other peer that contains data that are of interest • Relying on the transitivity of the defined mappings, the system tries to extract mappings between schemas that have no defined mapping
  • 20. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/20 • This approach is generally used when the shared data are defined based on ontologies and taxonomies as proposed for the semantic web • It uses machine learning techniques to automatically extract the mappings between the shared schemas • The extracted mappings are stored over the network, in order to be used for processing future queries Mapping Based on Machine Learning
  • 21. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/21 Common Agreement Mapping • Some (cooperating) peers must agree on a Common Schema Description (CSD) • Given a CSD, a peer schema can be specified using views ➡ Similar to the LAV approach • When a peer decides to share data, it needs to map its local schema to the CSD
  • 22. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/22 Querying over P2P Systems • P2P networks provide basic query routing ➡ Sufficient for simple, exact-match queries, e.g. with a DHT • Supporting more complex queries, particularly in DHTs, is difficult • Main types of complex queries ➡ Top-k queries ➡ Join queries ➡ Range queries
  • 23. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/23 Top-k Query • Returns only k of the most relevant answers, ordered by relevance ➡ Like for a search engine • Scoring function (sf) determines the relevance (score) of answers to the query • Example SELECT * FROM Patient P WHERE (P.disease = “diabetes”) AND (P.height < 170) AND (P.weight > 70) ORDER BY sf(height, weight) STOP AFTER 10 ➡ Example of sf: weight − (height -100)
  • 24. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/24 General Model for Top-k Queries • Suppose we have: ➡ n data items ✦ items can be document, tuples, etc. ➡ m lists of n data items such that ✦ Each data item has ✓ a local score in each list ✓ an overall score computed based on its local scores in all lists using a given scoring function ✦ Each list ✓ contains all n data items (or item ids) ✓ is sorted in decreasing order of the local scores • The objective is: ➡ Given a scoring function, find the k data items whose overall scores are the highest
  • 25. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/25 Execution Cost of Top-k Queries • Two modes of access to a sorted list ➡ Sorted (sequential) access ✦ Starts with the first data item, then accesses each next item ➡ Random access ✦ Looks up a given data item in the list by its identifier (e.g. TID) • Given a top-k algorithm A and a database D (i.e. set of sorted lists), the cost of executing A over D is: ➡ Cost(A, D) = (#sorted-access * sorted-access-cost) + (#random-access * random-access-cost)
  • 26. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/26 Basic Top-k Algorithms • Fagin’s Algorithm (FA) ➡ General model of top-k queries using sorted lists ➡ Simple algorithm ✦ Do sorted access in parallel to the lists until at least k data items have been seen in all lists • Threshold Algorithm (TA) ➡ Proposed independently by several groups ➡ Efficient algorithm over sorted lists ➡ The basis for many TA-style distributed algorithms ✦ Mainly for DHTs ✦ Algorithms for unstructured or super-peer simpler
  • 27. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/27 TA • Similar to FA in doing sorted access to the lists ➡ But different stopping condition • Unlike FA, no need to wait until the lists give k items ➡ Once an item has been seen from a sorted access, get all its scores through random access • But how do we know that the scores of seen items are higher than those of unseen items? ➡ Use a threshold (T) to predict maximum possible score of unseen items ✦ based on the last scores seen in the lists under sorted access ➡ Then stop when there are at least k data items whose overall score ≥ T
  • 28. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/28 TA Example • Assume sf( ) = s1 + s2 + s3, k = 3, Y: {top seen items with overall scores} • At position 1 ➡ Look up the local scores of items d1, d2 and d3 in other lists using random access and compute their overall scores (which are 65, 63 and 70, respectively) ➡ Y = {(d1,70) (d2,65) (d3,63)}, T = 30 + 28 + 30 = 88 • Then ➡ At position 2, Y = {(d3,70) (d4,70) (d5,65)}, T = 84 ➡ At position 3, Y = {(d3,71) (d5,70) (d8,70)}, T = 80 ➡ At position 4, Y = same, T = 75 ➡ At position 5, Y = same, T = 72 ➡ At position 6, Y = same, T = 63 ✦ which is less than the overall score of the three data items in Y. Thus, TA stops • Note that the contents of Y at position 6 is exactly the same as at position 3
  • 29. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/29 Improvement over TA: BPA • Best Position Algorithm • Main idea: keep track of the positions (and scores) of the items seen under sorted or random access ➡ Enables BPA to stop as soon as possible ✦ In the previous example, BPA stops at position 3 • Best position = the greatest seen position in a list such that any position before it is also seen ➡ Thus, we are sure that all positions between 1 and best position have been seen • Stopping condition ➡ Based on best positions overall score, i.e. the overall score computed based on the best positions in all lists
  • 30. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/30 Top-k Query Processing in DHTs • Given ➡ A DHT network ➡ T : a set of tuples which are stored in the DHT ➡ Q : a top-k query ➡ sf : a scoring function • Goal ➡ Retrieve efficiently the k tuples stored in the DHT whose scores are the highest according to Q and sf ➡ While avoiding centralized data storage • DHTop algorithm ➡ TA style
  • 31. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/31 Data Storage Mechanism • Two complementary methods for storing tuples in the DHT ➡ Tuple storage: each tuple of a relation is stored in the DHT using its tuple’s identifier (e.g. primary key) ✦ Allows to retrieve tuples using their identifier ➡ Attribute storage: the values of some attributes of a tuple are stored individually in the DHT ✦ Acts as secondary indices ✦ Good support for exact match queries
  • 32. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/32 Tuple Storage Method • Let ➡ R (a1, a2, …, am) be a relation ➡ t 〈v1, v2, …, vm〉 be a tuple of R ➡ v1 be the primary key of tuple t ➡ h : a hash function that hashes its inputs into a DHT key • To store tuple t in the DHT, a peer does as follows: ➡ ts_key = h(R, v1); ➡ put(ts_key, v1, v2, …, vm );
  • 33. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/33 Attribute-value storage • Domain partitioning ➡ Let Da be the domain of an attribute a ➡ We partition Da into n nonempty sub-domains d1, d2, ..., dn ➡ Example: ✦ Attribute “weight”, with domain [0..200] in kilograms, can be partitioned into n=40 sub-domains [0..5), [5..10), …, [190..195), [195..200] • Exploitation by peers ➡ All peers know the sub-domains of each attribute ➡ Thus, each peer can locally execute the following function: ✦ sd(a, v) : returns the sub-domain of attribute a to which value v belongs
  • 34. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/34 Attribute-Value Storage (cont’d) • Let ➡ R(a1, a2, …, am) be a relation ➡ t v1, v2, …, vm be a tuple of R ➡ ts_keyt : the key used for storing tuple t in the DHT, i.e. h(R, v1); • For storing the value v2 of attribute a2 in the DHT : ➡ let di be the sub-domain to which v2 belongs, i.e. di = sd(a2, v2); avs_key h(R, a2, di); put(avs_key, v2 , ts_keyt ); • Two important features: 1. After retrieving an attribute value, we are able to retrieve its entire tuple 2. The values that are “relatively close” are stored at the same peer
  • 35. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/35 DHTop • Two phases, executed by the peer where Q is originated • Phase 1: Prepare ordered lists of attributes’ sub-domains ➡ For each scoring attribute a : ✦ Step 1: create a list of a’s sub-domains, denoted by La ✦ Step 2: remove useless sub-domains by considering Q’s conditions ✓ E.g. condition a = c , remove all sub-domains except sub-domain of c ✦ Step 3: sort La according to the positive impact of its sub-domains on the scoring function
  • 36. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/36 DHTop (cont’d) • Phase 2: Continuously retrieve attribute values and their tuples until finding the k top tuples ➡ For each scoring attribute a do in parallel i=1 Repeat 1. Ask the peer p that maintains attribute values for La[i] (i.e. i-th sub- domain in the list) to return its attribute values in order of their positive impact on the scoring function 2. After receiving each attribute value v o Retrieve the entire tuple o Check End-Condition: are there at least k tuples (among the retrieved tuples) whose scores are greater than the threshold? o If end-condition holds, then exit 3. If all values maintained by p are received then o i = i + 1 Until (end-condition holds) or (i ≥ number of a’s sub-domains)
  • 37. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/37 DHTop Threshold • Let a1, a2, ..., am be the scoring attributes, and v1, v2, ..., vm be the last values retrieved for them • Let f be the scoring function • The threshold is = f(v1, v2, …, vm)
  • 38. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/38 Top-k Query Processing in Unstructured Systems • Fully Decentralized (FD) algorithm ➡ Fully decentralized query execution ➡ No centralized information ➡ Considers dynamicity of peers ➡ Simple, efficient and fault-tolerant ✦ Many optimizations possible
  • 39. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/39 FD Algorithm Overview 1. Query Forward ➡ If TTL > 0, send Q to your neighbors 2. Local query execution ➡ Extract the k local top scores 3. Wait ➡ Wait to receive from the neighbors their k top scores ➡ The wait time is based on the received TTL, network parameters and peer’s local processing parameters 4. Merge-and-Backward ➡ Extract k top scores from the local and received scores ➡ Send the k top scores to your parent 5. Data retrieval (at the query originator) ➡ Retrieve the overall top-k data using the final top scores
  • 40. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/40 State Transition Diagram
  • 41. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/41 FD Optimizations • What if a peer receives a score-list after its wait time has expired? ➡ Urgent Score-list: a mechanism to backward a score-list to another peer still in the wait phase • What if the parent of a peer p leave the system? ➡ If p has a neighbor that is not p’s child, the score-list can be sent to it as an urgent score-list ➡ If p has not such a neighbor, it can send its merged score-list directly to the query originator • Return results ASAP ➡ Without waiting for the entire result set
  • 42. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/42 Join Query Processing in DHTs • A DHT relies on hashing to store and locate data ➡ Basis for parallel hash join algorithms • Basic solution in the context of the PIER P2P system ➡ Let us call it PIERjoin ➡ Assume that the joined relations and the result relations have a home which are the peers that store horizontal fragments of the relation ✦ Recall def. of home from Chapter 8 ➡ Make use of the put method for distributing tuples onto a set of peers based on their join attribute so that tuples with the same join attribute values are stored at the same peers ➡ Then apply the probe/join phase
  • 43. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/43 PIERjoin Algorithm 1. Multicast phase ➡ The query originator peer multicasts Q to all peers that store tuples of the join relations R and S, i.e., their homes. 2. Hash phase ➡ Each peer that receives Q scans its local relation, searching for the tuples that satisfy the select predicate (if any) ➡ Then, it sends the selected tuples to the home of the result relation, using put operations ➡ The DHT key used in the put operation uses the home of the result relation and the join attribute 3. Probe/join phase ➡ Each peer in the home of the result relation, upon receiving a new tuple, inserts it in the corresponding hash table, probes the opposite hash table to find matching tuples and constructs the result joined tuples
  • 44. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/44 Range Query Processing • Range query ➡ WHERE clause of the form “attribute A in range [a; b]” • Difficult to support in structured P2P systems, in particular, DHTs ➡ Hashing tends to destroy the ordering of data that is useful in finding ranges quickly • Two main approaches for supporting range queries in structured P2P systems ➡ Extend a DHT with proximity or order-preserving properties ✦ Problem: data skew that can result in peers with unbalanced ranges, which hurts load balancing ➡ Maintain the key ordering with a tree-based structure ✦ Better at maintaining balanced ranges of keys
  • 45. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/45 BATON • BATON (BAlanced Tree Overlay Network) • Organizes peers as a balanced binary tree ➡ Each node of the tree is maintained by a peer ➡ The position of a node is determined by a (level, number) tuple, with level starting from 0 at the root, number starting from 1 at the root and sequentially assigned using in-order traversal ➡ Each tree node stores links to its parent, children, adjacent nodes and selected neighbor nodes that are nodes at the same level ➡ Two routing tables: a left routing table and a right routing table store links to the selected neighbor nodes
  • 46. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/46 BATON Structure-tree Index • Each node (or peer) is assigned a range of values ➡ Maintained at the routing table of each link ➡ Required to be to the right of the range managed by its left subtree and less than the range managed by its right subtree
  • 47. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/47 Range Query Processing in BATON Input: Q, a range query in the form [a,b] Output: T: result relation 1. Search for the peer storing the lower bound of the range At query originator node do find peer p that holds value a send Q to p 2. A peer p that receives Q (from query originator or its left adjacent peer) searches for local tuples and sends Q to its right adjacent node At each peer p that receives Q Tp = Range(p) [a,b] send Tp to query originator If (Range(RighAdjacent(p)) [a,b]) not empty send Q to right adjacent peer of p • With X nodes covering the range, Q is answered in O(log n + X) steps
  • 48. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/48 Example of Range Query Execution • Consider Q with range [7; 45] issued at node 7 • First, execute an exact match query looking for a node containing the lower bound of the range (see dashed line) • Since the lower bound is in node 4’s range, check locally for tuples belonging to the range and forward Q to its adjacent right node (node 9) • Node 9 checks for local tuples belonging to the range and forwards Q to node 2 • Nodes 10, 5, 1 and 6 receive Q, check for local tuples and contact their respective right adjacent node until the node containing the upper bound of the range is reached
  • 49. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/49 Replica Consistency • To increase data availability and access performance, P2P systems replicate data, however, with very different levels of replica consistency ➡ The earlier, simple P2P systems such as Gnutella and Kazaa deal only with static data (e.g., music files) and replication is “passive” as it occurs naturally as peers request and copy files from one another (basically, caching data) • In more advanced P2P systems where replicas can be updated, there is a need for proper replica management techniques • Replica consistency in DHTs ➡ Basic support - Tapestry ➡ Replica reconciliation - OceanStore
  • 50. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/50 Tapestry • Decentralized object location and routing on top of a structured overlay • Routes messages to logical end-points (i.e., not associated with physical location), such as nodes or object replicas. ➡ This enables message delivery to mobile or replicated endpoints in the presence of network instability • Location and routing ➡ Let O be an object identified by id(O), the insertion of O involves two nodes: the server node (noted ns) that holds O and the root node (noted nr) that holds a mapping in the form (id(O); ns) indicating that the object identified by id(O) is stored at node ns ➡ The root node is dynamically determined by a globally consistent deterministic algorithm
  • 51. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/51 Object Publishing in Tapestry • When O is inserted into ns, ns publishes id(O) at its root node by routing a message from ns to nr containing the mapping (id(O); ns) • This mapping is stored at all nodes along the message path • During a location query (e.g., “id(O)?”, the message that looks for id(O) is initially routed towards nr, but it may be stopped before reaching it once a node containing the mapping (id(O); ns) is found • For routing a message to id(O)’s root, each node forwards this message to its neighbor whose logical identifier is the most similar to id(O)
  • 52. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/52 Replica Management in Tapestry • Each node represents a peer and contains the peer’s logical identifier in hexadecimal format • Two replicas O1 and O2 of object O (e.g., a book file) are inserted into distinct peers (O1 at peer 4228 and O2 at peer AA93). The identifier of O1 is equal to that of O2 (i.e., 4378) • When O1 is inserted into its server node (peer 4228), the mapping (4378; 4228) is routed from peer 4228 to peer 4377 (the root node for O1’s identifier) • As the message approaches the root node, the object and the node identifiers become increasingly similar • In addition, the mapping (4378; 4228) is stored at all peers along the message path
  • 53. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/53 OceanStore • OceanStore is a data management system designed to provide continuous access to persistent information • Relies on Tapestry and assumes untrusted powerful servers connected by high-speed links • To improve performance, data are allowed to be cached anywhere, anytime • Allows concurrent updates on replicated objects; it relies on reconciliation to assure data consistency
  • 54. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/54 Reconciliation in OceanStore • Ri and ri denote, respectively, a primary and a secondary copy of object R • Nodes n1 and n2 are concurrently updating R as follows ➡ Nodes that hold primary copies of R, called the master group of R, are responsible for ordering updates ➡ (a) n1 and n2 perform tentative updates on their local secondary replicas and send these updates to the master group of R as well as to other random secondary replicas ➡ (b) The tentative updates are ordered by the master group based on timestamps assigned by n1 and n2, and epidemically propagated among secondary replicas ➡ (c) Once the master group obtains an agreement, the result of updates is multicast to secondary replicas
  • 55. Distributed DBMS ©M. T. Özsu & P. Valduriez Ch.16/55 Conclusion • Advanced P2P applications will need high-level data management services • Various P2P networks will improve ➡ Network-independence crucial to exploit and combine them • Many technical issues ➡ Decentralized schema management, complex query processing, transaction support and replication, and data privacy • Important to characterize applications that can most benefit from P2P with respect to other distributed architectures