Distributed Databases – Advanced Concepts Chapter 25 in Textbook.

Slides:



Advertisements
Similar presentations
Types of Distributed Database Systems
Advertisements

CS3771 Today: deadlock detection and election algorithms  Previous class Event ordering in distributed systems Various approaches for Mutual Exclusion.
Distributed Systems Distributed Coordination. Introduction Concurrent processes in same system –Common memory and clock –Easy to see order of events Concurrent.
Lock-Based Concurrency Control
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Lectures 25-26: Distributed Coordination (Ch 18)
Chapter 18: Distributed Coordination Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 18 Distributed Coordination Event Ordering.
Chapter 16: Distributed Coordination Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Apr 11, 2005 Chapter 16 Distributed.
(c) Oded Shmueli Distributed Recovery, Lecture 7 (BHG, Chap.7)
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 17 Distributed Coordination Event Ordering Mutual Exclusion Atomicity Concurrency.
Distributed Coordination CS 3100 Distributed Coordination1.
ICS 421 Spring 2010 Distributed Transactions Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 3/16/20101Lipyeow.
What we will cover…  Distributed Coordination 1-1.
Transaction Management and Concurrency Control
Chapter 18-1: Distributed Coordination Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 18 Distributed Coordination Chapter.
Lecture-12 Concurrency Control in Distributed Databases
Chapter 18: Distributed Coordination (Chapter 18.1 – 18.5)
©Silberschatz, Korth and Sudarshan19.1Database System Concepts Distributed Transactions Transaction may access data at several sites. Each site has a local.
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
Distributed Commit. Example Consider a chain of stores and suppose a manager – wants to query all the stores, – find the inventory of toothbrushes at.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Distributed Databases
04/20/2005Yan Huang - CSCI5330 Database Implementation – Distributed Database Systems Distributed Database Systems.
Distributed Deadlocks and Transaction Recovery.
III. Current Trends: 2 - Distributed DBMSsSlide 1/47 III. Current Trends Distributed DBMSs: Advanced Concepts 3C13/D63C13/D6.
04/18/2005Yan Huang - CSCI5330 Database Implementation – Distributed Database Systems Distributed Database Systems.
DISTRIBUTED DATABASE SYSTEM.  A distributed database system consists of loosely coupled sites that share no physical component  Database systems that.
©Silberschatz, Korth and Sudarshan19.1Database System Concepts 1 Chapter 19: Distributed Databases Heterogeneous and Homogeneous Databases Distributed.
Chapter 19 Recovery and Fault Tolerance Copyright © 2008.
Lecture 16- Distributed Databases Advanced Databases Masood Niazi Torshiz Islamic Azad University- Mashhad Branch
Distributed Transactions Chapter 13
Operating Systems Distributed Coordination. Topics –Event Ordering –Mutual Exclusion –Atomicity –Concurrency Control Topics –Event Ordering –Mutual Exclusion.
Chapter 11 Concurrency Control. Lock-Based Protocols  A lock is a mechanism to control concurrent access to a data item  Data items can be locked in.
Chapter 15 Concurrency Control Yonsei University 1 st Semester, 2015 Sanghyun Park.
O/S 4740 Distributed Coordination. Event Ordering In a Centralized system, we have common memory and clock, –So we can always determine the order that.
Databases Illuminated
Distributed Transaction Management. Outline Introduction Concurrency Control Protocols  Locking  Timestamping Deadlock Handling Replication.
Chapter 18: Distributed Coordination Adapted to COP4610 by Robert van Engelen.
Chapter 19 Distributed Databases. 2 Distributed Database System n A distributed DBS consists of loosely coupled sites that share no physical component.
Introduction to Distributed Databases Yiwei Wu. Introduction A distributed database is a database in which portions of the database are stored on multiple.
Multidatabase Transaction Management COP5711. Multidatabase Transaction Management Outline Review - Transaction Processing Multidatabase Transaction Management.
Chapter 16: Distributed Coordination Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Apr 11, 2005 Outline n Event.
©Silberschatz, Korth and Sudarshan18.1Database System Concepts 3 rd Edition 1 Chapter 18: Distributed Databases Distributed Data Storage Network Transparency.
Chapter 18: Distributed Coordination Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Apr 11, 2005 Chapter 18 Distributed.
Academic Year 2014 Spring Academic Year 2014 Spring.
CS3771 Today: Distributed Coordination  Previous class: Distributed File Systems Issues: Naming Strategies: Absolute Names, Mount Points (logical connection.
Topics in Distributed Databases Database System Implementation CSE 507 Some slides adapted from Navathe et. Al and Silberchatz et. Al.
Silberschatz and Galvin  Operating System Concepts Module 18: Distributed Coordination Event Ordering Mutual Exclusion Atomicity Concurrency.
Database Recovery Techniques
Chapter 18: Distributed Coordination
Lecture 17- Distributed Databases (continued)
Chapter 19: Distributed Databases
Concurrency Control.
Multiple Granularity Granularity is the size of data item  allowed to lock. Multiple Granularity is the hierarchically breaking up the database into portions.
Database System Implementation CSE 507
Distributed Transactions
Commit Protocols CS60002: Distributed Systems
RELIABILITY.
Outline Announcements Fault Tolerance.
CSIS 7102 Spring 2004 Lecture 6: Distributed databases
Distributed Database Systems
Chapter 10 Transaction Management and Concurrency Control
Chapter 15 : Concurrency Control
Distributed Transactions
Exercises for Chapter 14: Distributed Transactions
Distributed Databases Recovery
Module 18: Distributed Coordination
CONCURRENCY Concurrency is the tendency for different tasks to happen at the same time in a system ( mostly interacting with each other ) .   Parallel.
Presentation transcript:

Distributed Databases – Advanced Concepts Chapter 25 in Textbook

Overview  Structure for handling distributed transactions.  Ensuring atomicity  Commit Protocols.  2-phase commit.  Handling failures with 2PC.  Ensuring consistency  Concurrency control.  Locking.  Handling deadlocks.  False cycles.  Distribution in Oracle.

Distributed Transactions  Transaction may access data at several sites. 1. Each site has a local transaction manager responsible for:  Maintaining a log for recovery purposes  Participating in coordinating the concurrent execution of the transactions executing at that site. 2. Each site has a transaction coordinator responsible for:  Starting the execution of transactions that originate at the site.  Distributing sub-transactions at appropriate sites for execution.  Coordinating the termination of each transaction that originates at the site, which may result in the transaction being committed at all sites or aborted at all sites.

Transaction System Architecture

Commit Protocols  Commit protocols are used to ensure atomicity across sites.  a transaction which executes at multiple sites must either be committed at all the sites, or aborted at all the sites.  not acceptable to have a transaction committed at one site and aborted at another  The two-phase commit (2PC) protocol is widely used.

Two-Phase Commit (2PC)  Assumes fail-stop model – failed sites simply stop working, and do not cause any other harm, such as sending incorrect messages to other sites.  Execution of the protocol is initiated by the coordinator after the last step of the transaction has been reached.  The protocol involves all the sites at which the transaction executed.  Let T be a transaction initiated at site S i, and let the transaction coordinator at S i be C i.

Structure Network CkCk SkSk CjCj SjSj CiCi SiSi CmCm SmSm T

Phase 1: Obtaining a Decision  Coordinator asks all participants to prepare to commit transaction T.  C i adds the records to the log and forces log to stable storage.  sends prepare T messages to all sites at which T executed.  Upon receiving message, transaction manager at site determines if it can commit the transaction.  if not, add a record to the log and send abort T message to C i  if the transaction can be committed, then:  add the record to the log  force all records for T to stable storage  send ready T message to C i

Phase 2: Recording the Decision  T can be committed if C i received a ready T message from all the participating sites: otherwise T must be aborted.  Coordinator adds a decision record, or, to the log and forces record onto stable storage. Once the record is in stable storage it is irrevocable (even if failures occur).  Coordinator sends a message to each participant informing it of the decision (commit or abort).  Participants take appropriate action locally.

Handling of Failures – Site Failure (S k ) When site S k recovers, it examines its log to determine the fate of transactions active at the time of the failure.  Log contain record: site executes redo (T)  Log contains record: site executes undo (T)  Log contains record: site must consult C i to determine the fate of T.  If T committed, redo (T)  If T aborted, undo (T)  The log contains no control records concerning T replies that S k failed before responding to the prepare T message from C i  since the failure of S k precludes the sending of such a response C i must abort T  S k must execute undo (T)

Handling of Failures – Coordinator’s Failure (C i )  If coordinator C i fails while the commit protocol for T is executing then participating sites must decide on T’s fate: 1. If an active site contains a record in its log, then T must be committed. 2. If an active site contains an record in its log, then T must be aborted. 3. If some active participating site does not contain a record in its log, then the failed coordinator C i cannot have decided to commit T. Can therefore abort T. 4. If none of the above cases holds, then all active sites must have a record in their logs, but no additional control records (such as of ). In this case active sites must wait for C i to recover, to find decision.  Blocking problem : active sites may have to wait for failed coordinator to recover.

Concurrency Control  Modify concurrency control schemes for use in distributed environment.  We assume that each site participates in the execution of a commit protocol to ensure global transaction atomicity.  We assume all replicas of any item are updated immediately.  Concurrency Control techniques:  Locking.  Time-stamping.

Locking in a Distributed Environment  Same rules as in centralized.  Shared and Exclusive locks.  Each transaction follows 2PL.  Problem when requesting locks on replicated data.  Solutions:  Single Lock Manager.  Distributed Lock Manager.  Primary Copy Protocol.  Majority Protocol. Network X SkSk X SjSj SiSi X SmSm T T Begin Xlock(x) :

Single Lock Manager  System maintains a single lock manager that resides in a single chosen site, say S i.  When a transaction needs to lock a data item, it sends a lock request to S i and lock manager determines whether the lock can be granted immediately:  If yes, lock manager sends a message to the site which initiated the request.  If no, request is delayed until it can be granted, at which time a message is sent to the initiating site.

Single Lock Manager  Once it gets the lock, the transaction can read the data item from any one of the sites at which a replica of the data item resides.  Writes must be performed on all replicas of a data item.  Advantages of scheme:  Simple implementation.  Simple deadlock handling.  Disadvantages of scheme are:  Bottleneck: lock manager site becomes a bottleneck.  Vulnerability: system is vulnerable to lock manager site failure.

Distributed Lock Manager  In this approach, functionality of locking is implemented by lock managers at each site.  Lock managers control access to local data items.  But special protocols may be used for replicas.  Advantage: work is distributed and can be made robust to failures.  Disadvantage: deadlock detection is more complicated  Lock managers cooperate for deadlock detection.  More on this later.  Two variants of this approach:  Primary copy.  Majority protocol.

Primary Copy  Choose one replica of data item to be the primary copy.  Site containing the replica is called the primary site for that data item.  Different data items can have different primary sites.  When a transaction needs to lock a data item Q, it requests a lock at the primary site of Q.  Implicitly gets lock on all replicas of the data item.  After it gets the lock from primary site, it can read from any of the replicas.  Advantage: Concurrency control for replicated data handled similarly to unreplicated data - simple implementation.  Disadvantage: If the primary site of Q fails, Q is inaccessible even though other sites containing a replica may be accessible.

Majority Protocol  Local lock manager at each site administers lock and unlock requests for data items stored at that site.  When a transaction wishes to lock an unreplicated data item Q residing at site S i, a message is sent to S i ‘s lock manager.  If Q is locked in an incompatible mode, then the request is delayed until it can be granted.  When the lock request can be granted, the lock manager sends a message back to the initiator indicating that the lock request has been granted.

Majority Protocol  In case of replicated data  If Q is replicated at n sites, then a lock request message must be sent to more than half of the n sites in which Q is stored.  The transaction does not operate on Q until it has obtained a lock on a majority of the replicas of Q.  When writing the data item, transaction performs writes on all replicas.  Advantage:  Can be used even when some sites are unavailable  details on how handle writes in the presence of site failure later  Disadvantage:  Requires 2(n/2 + 1) messages for handling lock requests, and (n/2 + 1) messages for handling unlock requests.  Potential for deadlock even with single item - e.g., each of 3 transactions may have locks on 1/3rd of the replicas of a data.

Deadlock Handling Consider the following two transactions and history, with item X and transaction T 1 at site 1, and item Y and transaction T 2 at site 2: T 1 : write(X) write(Y) T 2 : write(Y) write(X) XLock(X) write(X) Xlock(Y) Wait Xlock(Y) write(Y) Xlock(X) Wait T 1 at site 1 Result: deadlock which cannot be detected locally at either site. T 2 at site 2

Deadlock Handling  How to detect deadlock from last slide?  Global Wait-for Graph + Local Wait-for Graphs.  Global WFG:  Constructed and maintained in a single site; the deadlock-detection coordinator.  2 Graphs:  Real graph: Real, but unknown, state of the system.  Constructed graph: Approximation generated by the coordinator through combining local WFGs. Network Coordinator Site S1S1 S2S2 T1T1 T2T2 Local WFG T2T2 T1T1 T1T1 T2T2 Global WFG

Deadlock Handling  The global wait-for graph can be constructed when:  a new edge is inserted in or removed from one of the local wait-for graphs. OR  a number of changes have occurred in a local wait-for graph. OR  the coordinator needs to invoke cycle-detection.  If the coordinator finds a cycle:  It selects a victim and notifies all sites.  The sites roll back the victim transaction.

Local and Global Wait-For Graphs Local Global

Example Wait-For Graph for False Cycles Initial state:

False Cycles  Suppose that starting from the state shown in figure, 1. T 2 releases resources at S 1  resulting in a message remove T 1  T 2 message from the Transaction Manager at site S 1 to the coordinator) 2. And then T 2 requests a resource held by T 3 at site S 2  resulting in a message insert T 2  T 3 from S 2 to the coordinator  Suppose further that the insert message reaches before the delete message  this can happen due to network delays.  The coordinator would then find a false cycle T 1  T 2  T 3  T 1  The false cycle above never existed in reality.

Unnecessary Rollbacks  Unnecessary rollbacks may result when deadlock has indeed occurred and a victim has been picked, and meanwhile one of the transactions was aborted for reasons unrelated to the deadlock.  Unnecessary rollbacks can result from false cycles in the global wait-for graph.

Distribution in Oracle  Self-read Pages