1 ICS 214B: Transaction Processing and Distributed Data Management Replication Techniques.

Slides:



Advertisements
Similar presentations
CM20145 Concurrency Control
Advertisements

Database Systems (資料庫系統)
1 Concurrency Control Chapter Conflict Serializable Schedules  Two actions are in conflict if  they operate on the same DB item,  they belong.
1 Lecture 11: Transactions: Concurrency. 2 Overview Transactions Concurrency Control Locking Transactions in SQL.
Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Concurrency Control II. General Overview Relational model - SQL  Formal & commercial query languages Functional Dependencies Normalization Physical Design.
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
Database Systems, 8 th Edition Concurrency Control with Time Stamping Methods Assigns global unique time stamp to each transaction Produces explicit.
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 12: Three-Phase Commits (3PC) Professor Chen Li.
CIS 720 Concurrency Control. Timestamp-based concurrency control Assign a timestamp ts(T) to each transaction T. Each data item x has two timestamps:
Distributed Systems Fall 2010 Replication Fall 20105DV0203 Outline Group communication Fault-tolerant services –Passive and active replication Highly.
Distributed Transaction Processing Some of the slides have been borrowed from courses taught at Stanford, Berkeley, Washington, and earlier version of.
Database Replication techniques: a Three Parameter Classification Authors : Database Replication techniques: a Three Parameter Classification Authors :
Transaction Management and Concurrency Control
CS 582 / CMPE 481 Distributed Systems
Quick Review of May 1 material Concurrent Execution and Serializability –inconsistent concurrent schedules –transaction conflicts serializable == conflict.
Transaction Management and Concurrency Control
Session - 14 CONCURRENCY CONTROL CONCURRENCY TECHNIQUES Matakuliah: M0184 / Pengolahan Data Distribusi Tahun: 2005 Versi:
Manajemen Basis Data Pertemuan 10 Matakuliah: M0264/Manajemen Basis Data Tahun: 2008.
Transaction Management
1 Distributed Databases CS347 Lecture 16 June 6, 2001.
Distributed Systems Fall 2009 Replication Fall 20095DV0203 Outline Group communication Fault-tolerant services –Passive and active replication Highly.
©Silberschatz, Korth and Sudarshan19.1Database System Concepts Distributed Transactions Transaction may access data at several sites. Each site has a local.
CS 425 / ECE 428 Distributed Systems Fall 2014 Indranil Gupta (Indy) Lecture 18: Replication Control All slides © IG.
1 ICS 214B: Transaction Processing and Distributed Data Management Distributed Database Systems.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
CMPT 401 Summer 2007 Dr. Alexandra Fedorova Lecture XI: Distributed Transactions.
CMPT Dr. Alexandra Fedorova Lecture XI: Distributed Transactions.
CS 603 Data Replication February 25, Data Replication: Why? Fault Tolerance –Hot backup –Catastrophic failure Performance –Parallelism –Decreased.
CMPT Dr. Alexandra Fedorova Lecture XI: Distributed Transactions.
Commit Protocols. CS5204 – Operating Systems2 Fault Tolerance Causes of failure: process failure machine failure network failure Goals : transparent:
CS162 Section Lecture 10 Slides based from Lecture and
04/18/2005Yan Huang - CSCI5330 Database Implementation – Distributed Database Systems Distributed Database Systems.
Replication March 16, Replication What is Replication?  A technique for increasing availability, fault tolerance and sometimes, performance 
1 Distributed and Replicated Data Seif Haridi. 2 Distributed and Replicated Data Purpose –Increase performance (parallel processing) –Increase safety.
TRANSACTION MANAGEMENT R.SARAVANAKUAMR. S.NAVEEN..
II.I Selected Database Issues: 2 - Transaction ManagementSlide 1/20 1 II. Selected Database Issues Part 2: Transaction Management Lecture 4 Lecturer: Chris.
Commit Algorithms Hamid Al-Hamadi CS 5204 November 17, 2009.
Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.
2/29/ Replication CSEP 545 Transaction Processing Philip A. Bernstein Sameh Elnikety Copyright ©2012 Philip A. Bernstein.
1 Concurrency Control Lecture 22 Ramakrishnan - Chapter 19.
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses are.
1 CSE 480: Database Systems Lecture 24: Concurrency Control.
Transaction Management Transparencies. ©Pearson Education 2009 Chapter 14 - Objectives Function and importance of transactions. Properties of transactions.
3/6/99 1 Replication CSE Transaction Processing Philip A. Bernstein.
1 Database Systems ( 資料庫系統 ) December 27, 2004 Chapter 17 By Hao-hua Chu ( 朱浩華 )
CSE 486/586 Distributed Systems Consistency --- 3
CSE 486/586, Spring 2012 CSE 486/586 Distributed Systems Replication Steve Ko Computer Sciences and Engineering University at Buffalo.
Multidatabase Transaction Management COP5711. Multidatabase Transaction Management Outline Review - Transaction Processing Multidatabase Transaction Management.
CSE 486/586, Spring 2014 CSE 486/586 Distributed Systems Transactions on Replicated Data Steve Ko Computer Sciences and Engineering University at Buffalo.
Jinze Liu. ACID Atomicity: TX’s are either completely done or not done at all Consistency: TX’s should leave the database in a consistent state Isolation:
Distributed DBMSPage © 1998 M. Tamer Özsu & Patrick Valduriez Outline Introduction Background Distributed DBMS Architecture Distributed Database.
Distributed Databases – Advanced Concepts Chapter 25 in Textbook.
CS 347: Parallel and Distributed Data Management Notes07: Data Replication Hector Garcia-Molina CS 347 Notes07.
Outline Introduction Background Distributed DBMS Architecture
Two phase commit.
Commit Protocols CS60002: Distributed Systems
RELIABILITY.
Outline Announcements Fault Tolerance.
Chapter 10 Transaction Management and Concurrency Control
Concurrency Unit 4.2 Dr Gordon Russell, Napier University
Distributed Database Management Systems
Distributed Transactions
Lecture 21: Replication Control
Atomic Commit and Concurrency Control
Distributed Databases Recovery
Concurrency Unit 4.2 Dr Gordon Russell, Napier University
Lecture 21: Replication Control
CIS 720 Concurrency Control.
Transactions, Properties of Transactions
Presentation transcript:

1 ICS 214B: Transaction Processing and Distributed Data Management Replication Techniques

ICS214BNotes 142 Data Replication Databasenode 1node 2node 3 item fragment

ICS214BNotes 143 Goals for Data replication –Higher throughput –Better response time –Higher availability Assumption: Reliable network, fail- stop nodes

ICS214BNotes 144 Basic Solution (for Concurrency Control) Treat each copy as an independent data item X1X2X3 Lock mgr X3 Lock mgr X2 Lock mgr X1 Tx i Tx j Tx k Object X has copies X1, X2, X3

ICS214BNotes 145 Read(X): –get shared X1 lock –get shared X2 lock –get shared X3 lock –read one of X1, X2, X3 –at end of transaction, release X1, X2, X3 locks X1 lock mgr X3 lock mgr X2 lock mgr read

ICS214BNotes 146 Write(X): –get exclusive X1 lock –get exclusive X2 lock –get exclusive X3 lock –write new value into X1, X2, X3 –at end of transaction, release X1, X2, X3 locks X1 X3 X2 lock write

ICS214BNotes 147 RAWA (read lock all, write lock all) Correctness OK –2PL  serializability Problem: Low availability X1 X3 X2 down!  cannot access X!

ICS214BNotes 148 Readers lock and access a single copy Writers lock all copies and update all copies Basic Solution — Improvement X1X2X3 reader has lock writer will conflict!

ICS214BNotes 149 ROWA Good availability for reads Poor availability for writes

ICS214BNotes 1410 Reminder With basic solution –use standard 2PL –use standard commit protocols (e.g., 2PC)

ICS214BNotes 1411 Another approach: Primary copy Select primary site All read/write locks requested at the primary site All data read at primary Updates are propagated to backups (using sequence numbers) Probability a transaction blocks = prob. that primary is down Availability is the same as the primary node X1 *X2X3 reader write lock writer

ICS214BNotes 1412 Update Propagate Options Immediate Write –Write all copies at the same time Deferred Write –Wait until commit

ICS214BNotes 1413 Electing a new primary Elect New Primary P new Make sure P new has committed T 0,…,T k and has locks for T k+1,…,T m Therefore, before each transaction Ti commits, we should ensure backups (potential future primaries) have Ti’s updates PRIMARY Backup 1 Backup n Committed: T1, T2, …, Tk Pending: T k+1, …, T m

ICS214BNotes 1414 Distributed Commit X1*X2X3 prepare to write new value lock, compute new value writer ok commit (write)

ICS214BNotes 1415 Example X1: 0 Y1: 0 Z1: 0 * X2: 0 Y2: 0 Z2: 0 T1: X  1; Y  1; T2: Y  2; T3: Z  3;

ICS214BNotes 1416 Local Commit X1 *X2X3 propagate update lock, write, commit writer Write(X): Get exclusive X1* lock Write new value into X1* Commit at primary; get sequence number Perform X2, X3 updates in sequence-number order...

ICS214BNotes 1417 Example t = 0 X1: 0 Y1: 0 Z1: 0 * X2: 0 Y2: 0 Z2: 0 T1: X  1; Y  1; T2: Y  2; T3: Z  3;

ICS214BNotes 1418 Example t = 1 X1: 1 Y1: 1 Z1: 3 * X2: 0 Y2: 0 Z2: 0 T1: X  1; Y  1; T2: Y  2; T3: Z  3; active at node 1 waiting for lock at node 1 active at node 1

ICS214BNotes 1419 Example t = 2 X1: 1 Y1: 2 Z1: 3 * X2: 0 Y2: 0 Z2: 0 T1: X  1; Y  1; T2: Y  2; T3: Z  3; committed active at 1 committed #2: X  1; Y  1 #1: Z  3

ICS214BNotes 1420 Example t = 3 X1: 1 Y1: 2 Z1: 3 * X2: 1 Y2: 2 Z2: 3 T1: X  1; Y  1; T2: Y  2; T3: Z  3; committed #1: Z  3 #2: X  1; Y  1 #3: Y  2

ICS214BNotes 1421 What good is RPWP-LC? primary backup updates can’t read! Answer: Can read “out-of-date” backup copy (also useful with 1-safe backups... later)

ICS214BNotes 1422 Basic Solution Read lock all; write lock all: RAWA Read lock one; write lock all: ROWA Read and write lock primary: RPWP –local commit: LC –distributed commit: DC

ICS214BNotes 1423 Comparison N = number of nodes with copies P = probability that a node is operational *: assuming the read/write waits until all sites are active **: assuming we don’t care if other backups are active

ICS214BNotes 1424 Failures in Primary Copy model Backup fails –Asks primary for “lost” updates Primary fails –Data unavailable

ICS214BNotes 1425 Mobile Primary (1) Elect new primary (2) Ensure new primary has seen all previously committed transactions (3) Resolve pending transactions (4) Resume processing primary backup

ICS214BNotes 1426 (1) Elections Similar to 3PC termination protocol –Nodes have IDs –Largest (or smallest) ID wins

ICS214BNotes 1427 (2) Ensure new primary has previously committed transactions primary new primarybackup committed: T1, T2 need to get and apply: T1, T2  cannot use local commit

ICS214BNotes 1428 Failed Nodes: Example now: primarybackupbackup - down--down- later: -down--down--down- later primarybackup still: P1P2P3 P1P2P3 P1P2P3 -down- commits T 1 commit T 2 (unaware of T1!)

ICS214BNotes 1429 (3) Resolve pending transactions primary new primarybackup T3? T3 in “W” state  should not use blocking commit T3 in “W” state

ICS214BNotes PC takes care of this problem! Option A –Failed node waits for:  commit info from active node, or  all nodes are up and recovering Option B –Majority voting

ICS214BNotes 1431 Node Recovery All transactions have commit sequence number Active nodes save update values “as long as necessary” Recovering node asks active primary for missed updates; applies in order

ICS214BNotes 1432 Example: Majority Commit C1 C2C3 CT1,T2,T3T1,T2T1,T3 PT3T2 WT4T4T4 state:

ICS214BNotes 1433 Example: Majority Commit t1: C1 fails t2: C2 new primary t3: C2 commits T1, T2, T3; aborts T4 t4: C2 resumes processing t5: C2 commits T5, T6 t6: C1 recovers; asks C2 for latest state t7: C2 sends committed and pending transactions; C2 involves C1 in any future transactions

ICS214BNotes safe vs. 1-safe Backups Distributed commit results in 2-safe backups primarybackup 1backup 2 (1) T end work (2) send data (3) get acks (4) commit time

ICS214BNotes 1435 Guarantee After transaction T commits at primary, any future primary will “see” T primarybackup 1backup 2 primary next primary backup 2 now: T1, T2, T3 later:

ICS214BNotes 1436 Performance Hit 3PC is very expensive –many messages –locks held longer (less concurrency) [Note: group commit may help] Can use 2PC –may have blocking –2PC still expensive [up to 1 second reported]

ICS214BNotes 1437 Alternative: 1-safe Commit transactions unilaterally at primary Send updates to backups as soon as possible primarybackup 1backup 2 (1) T end work (2) T commit (3) send data (4) purge data time

ICS214BNotes 1438 Problem: Lost Transactions primarybackup 1backup 2 primary next primary backup 2 now: T1, T2, T3 T1, T4, T5 later: T1 T1, T4

ICS214BNotes 1439 Claim Lost transaction problem tolerable –failures rare –only a “few” transactions lost

ICS214BNotes 1440 Primary Recovery with 1-safe When failed primary recovers, need to “compensate” for missed transactions primarybackup 2 backup 3 next primary backup 2 now: T1, T2, T3 T1, T4, T5 later: T1, T4, T5 T1, T4 T1, T4, T5 next primary T1, T2, T3, T3 -1, T2 -1, T4, T5 compensation

ICS214BNotes 1441 Log Shipping “Log shipping:” propagate updates to backup Backup replays log How to replay log efficiently? –e.g., elevator disk sweeps –e.g., avoid overwrites primarybackup log

ICS214BNotes 1442 So Far in Data Replication RAWA ROWA Primary copy –static  local commit  distributed commit –mobile primary  2-safe (blocking or non-blocking)  1-safe

ICS214BNotes 1443 Correctness with replicated data S 1 : r 1 [X 1 ]  r 2 [X 2 ]  w 1 [X 1 ]  w 2 [X 2 ]  Is this schedule serializable? X1X1 X2X2

ICS214BNotes 1444 One copy serializable (1SR) A schedule S on replicated data is 1SR if it is equivalent to a serial history of the same transactions on a one-copy database

ICS214BNotes 1445 To check 1SR Take schedule Treat r i [X j ] as r i [X] X j is copy of X w i [X j ] as w i [X] Compute P(S) If P(S) acyclic, S is 1SR

ICS214BNotes 1446 S 1 : r 1 [X 1 ]  r 2 [X 2 ]  w 1 [X 1 ]  w 2 [X 2 ] S 1 ’: r 1 [X]  r 2 [X]  w 1 [X]  w 2 [X] S 1 is not 1SR! Example T1T2T1T2 T2T1T2T1

ICS214BNotes 1447 Second example S 2 : r 1 [X 1 ]  w 1 [X 1 ]  w 1 [X 2 ] r 2 [X 1 ]  w 2 [X 1 ]  w 2 [X 2 ] S 2 ’: r 1 [X]  w 1 [X]  w 1 [X] r 2 [X]  w 2 [X]  w 2 [X] P(S 2 ):

ICS214BNotes 1448 Second example S 2 : r 1 [X 1 ]  w 1 [X 1 ]  w 1 [X 2 ] r 2 [X 1 ]  w 2 [X 1 ]  w 2 [X 2 ] S 2 ’: r 1 [X]  w 1 [X]  w 1 [X] r 2 [X]  w 2 [X]  w 2 [X] Equivalent serial schedule S S :

ICS214BNotes 1449 Next lecture Multiple fragments Network partitions