Presentation is loading. Please wait.

Presentation is loading. Please wait.

Replicated Databases. Reading Textbook: Ch.13 Textbook: Ch.13 FarkasCSCE 824 - Spring 20112.

Similar presentations


Presentation on theme: "Replicated Databases. Reading Textbook: Ch.13 Textbook: Ch.13 FarkasCSCE 824 - Spring 20112."— Presentation transcript:

1 Replicated Databases

2 Reading Textbook: Ch.13 Textbook: Ch.13 FarkasCSCE 824 - Spring 20112

3 Review Centralized DBMS Centralized DBMS Distributed DBMS Distributed DBMS –Data fragmentation and allocation Top-down design Top-down design Bottom-up design Bottom-up design –Transaction processing Serializability theorem Serializability theorem Locking protocols Locking protocols Reliability Reliability FarkasCSCE 824 - Spring 20113

4 Replicated Databases Multiple copies of the same data items (databases) Multiple copies of the same data items (databases) Consistency: Consistency: –Local consistency –Mutual consistency FarkasCSCE 824 - Spring 20114

5 Why Replication? System availability System availability Performance Performance Scalability Scalability Application requirements Application requirements FarkasCSCE 824 - Spring 20115

6 Risk of Replication Worse performance: updates must be applied to all replicas and synchronized Worse performance: updates must be applied to all replicas and synchronized Worse availability: some algorithms require multiple replicas to be operational for any of them to be used Worse availability: some algorithms require multiple replicas to be operational for any of them to be used FarkasCSCE 824 - Spring 20116

7 Transaction Correctness 2-Phase Locking – serializability 2-Phase Locking – serializability 2-Phase Commit – reliability 2-Phase Commit – reliability Replica control – mutual consistency Replica control – mutual consistency –Database design: local vs. global transactions –Database consistency: strong consistency vs. weak consistency –Location of updates: master vs. distributed –Update propagation: eager vs. lazy –Degree of transparency: limited vs. full FarkasCSCE 824 - Spring 20117

8 Mutual Consistency vs. Transaction Consistency Transaction consistency: global serializability Transaction consistency: global serializability Mutual consistency: replicas having the same values Mutual consistency: replicas having the same values –Strong: all replicas have the same value at the end of the execution of an update transaction –Quorum: a quorum of replicas have the same value –Weak: eventually the values of all replicas become identical FarkasCSCE 824 - Spring 20118

9 FarkasCSCE 824 - Spring 201199 Replica Control Hides replication from transaction Hides replication from transaction Knows location of all replicas Knows location of all replicas Translates transaction’s request to access an item into request to access particular replica(s) Translates transaction’s request to access an item into request to access particular replica(s) Maintains some form of mutual consistency Maintains some form of mutual consistency

10 One-Copy Serializability (1SR) Extension of the serializability theory Extension of the serializability theory Effects of transactions on replicated data items should be the same as if they had been performed one at-a-time on a single set of date items Effects of transactions on replicated data items should be the same as if they had been performed one at-a-time on a single set of date items FarkasCSCE 824 - Spring 201110

11 FarkasCSCE 824 - Spring 201111 7/22/99 11 Example Replication Transaction x1 x2 x3 Issues –May reduce performance (complex operations) –Too expensive –Can’t control when replicas are updated

12 Replica Control Pessimistic replica control: at most one group can make an update – mutual consistency at all times Pessimistic replica control: at most one group can make an update – mutual consistency at all times Optimistic replica control: system must be available at all times. Correct if there is any violation of mutual consistency Optimistic replica control: system must be available at all times. Correct if there is any violation of mutual consistency FarkasCSCE 824 - Spring 201112

13 FarkasCSCE 824 - Spring 20111313 Read One / Write All Replica Control Pessimistic approach Pessimistic approach Read the nearest replica Read the nearest replica Write all replicas Write all replicas –Synchronous : before transaction commits –Asynchronous case: eventually Advantage: Advantage:  Mutual consistency  Performance benefits: reads transactions Disadvantage: availability is not always guaranteed Disadvantage: availability is not always guaranteed E.g., Primary site approach E.g., Primary site approach

14 Primary Site – static Primary site: most recent copy Primary site: most recent copy What happens if the network is partitioned? What happens if the network is partitioned? FarkasCSCE 824 - Spring 201114 DB0 DB4 DB2 DB5 DB3 DB1 Primary 1 2 DB6

15 Majority Approach The group that contains the majority of the sites can process an update The group that contains the majority of the sites can process an update FarkasCSCE 824 - Spring 201115 DB0 DB4 DB2 DB5 DB3 DB1 1 DB6

16 FarkasCSCE 824 - Spring 201116 Majority Approach The group that contains the majority of the sites can process an update The group that contains the majority of the sites can process an update Farkas CSCE 824 - Spring 2011 16 DB0 DB4 DB2 DB5 DB3 DB1 1 DB6 2  (N+1)/2 

17 Majority Approach Advantages: more flexible than primary site Advantages: more flexible than primary site Disadvantages: zero availability may still happen Disadvantages: zero availability may still happen Who has the most recent copy? Who has the most recent copy? –Version number: Each site assigns a version number to the copy (initially VN=0) Each site assigns a version number to the copy (initially VN=0) After an update, the VN is incremented by 1 After an update, the VN is incremented by 1 FarkasCSCE 824 - Spring 201117

18 Quorum Consensus Each sites are not equal Each sites are not equal Special case of majority approach Special case of majority approach FarkasCSCE 824 - Spring 201118 DB0 DB4 DB2 DB5 DB3 DB1 W=5 DB6 W=2 W=15 W=1 W=3

19 Other Approaches Dynamic Linear: order sites linearly to calculate majority Dynamic Linear: order sites linearly to calculate majority Token-based primary site (moving token): change the location of the primary site Token-based primary site (moving token): change the location of the primary site FarkasCSCE 824 - Spring 201119

20 Pessimistic Replica Control Advantages: Advantages: –Mutual consistency at all times –Know the latest version ( between two consecutive updates, there is a site in common) Disadvantage: Disadvantage: –May result in zero availability FarkasCSCE 824 - Spring 201120

21 Optimistic Replica Control Goal: availability at all time Goal: availability at all time Issues: consistency may not be guaranteed Issues: consistency may not be guaranteed –Need an algorithm to detect whether an inconsistency occurred –Take actions to fix any inconsistencies FarkasCSCE 824 - Spring 201121

22 Example Optimistic Alg. Two partitions P1, P2 Two partitions P1, P2 Assumption: separately, P1 and P2 produces serializable histories Assumption: separately, P1 and P2 produces serializable histories Need: after P1 and P2 joins again: Detect which transactions violate global serializability Need: after P1 and P2 joins again: Detect which transactions violate global serializability FarkasCSCE 824 - Spring 201122

23 Example cont. Items read by transaction T: read(T) Items read by transaction T: read(T) Items written by transaction T: write(T) Items written by transaction T: write(T) Assume: write(T)  read(T) Assume: write(T)  read(T) Transactions in P1: T 1i, in P2: T 2i Transactions in P1: T 1i, in P2: T 2i FarkasCSCE 824 - Spring 201123

24 Example cont. Precedence graph: G Precedence graph: G –Nodes: {T 11, …,T 1n, T 21, …, T 2m } –Edges: Dependency edge (ripple effect): there is an edge T ij  T ik if j<k and there is a data item d, s.t., d  write (T ij )  read(T ik ) and there is no l s.t., j<l<k and d is in the write set in T il (to consider dirty read within the same partition) Dependency edge (ripple effect): there is an edge T ij  T ik if j<k and there is a data item d, s.t., d  write (T ij )  read(T ik ) and there is no l s.t., j<l<k and d is in the write set in T il (to consider dirty read within the same partition) FarkasCSCE 824 - Spring 201124

25 Example cont. Precendence edges: there is an edge T ij  T ik if j<k and there is a data item d, s.t., d  read(T ij )  write(T ik ) and there is no l s.t., j<l<k and d is in the write set in T il (to consider the first transaction to write a data item after a read within the same partition) Precendence edges: there is an edge T ij  T ik if j<k and there is a data item d, s.t., d  read(T ij )  write(T ik ) and there is no l s.t., j<l<k and d is in the write set in T il (to consider the first transaction to write a data item after a read within the same partition) FarkasCSCE 824 - Spring 201125

26 Example cont. Interference edges: there is an edge T 1i  T 2j if j<k and there is a data item d, s.t., d  read(T 1i )  write(T 2j ) or vice verse (to consider when T 1i reads something written by T 2j ) Interference edges: there is an edge T 1i  T 2j if j<k and there is a data item d, s.t., d  read(T 1i )  write(T 2j ) or vice verse (to consider when T 1i reads something written by T 2j ) FarkasCSCE 824 - Spring 201126

27 Example cont. Theorem: The combined histories are correct iff the precendense graph is acyclic Theorem: The combined histories are correct iff the precendense graph is acyclic Correct inconsistencies: remove (undo) transactions that make the graph cyclic Correct inconsistencies: remove (undo) transactions that make the graph cyclic FarkasCSCE 824 - Spring 201127

28 FarkasCSCE 824 - Spring 201128 Summary Correctness: If the transactions are ACID, local execution in serializable, distributed transactions are reliable, and update replication is synchronous then distributed transactions are globally atomic & serializable Correctness: If the transactions are ACID, local execution in serializable, distributed transactions are reliable, and update replication is synchronous then distributed transactions are globally atomic & serializable Performance: Performance: –Applications: transactions are not always serializable (e.g., WS-transactions) –Replication: update propagation is not always asynchronous Compensating transactions Compensating transactions

29 FarkasCSCE 824 - Spring 201129 Next Class Review distributed databases Design Concurrency control ReliabilityReplication


Download ppt "Replicated Databases. Reading Textbook: Ch.13 Textbook: Ch.13 FarkasCSCE 824 - Spring 20112."

Similar presentations


Ads by Google