Distributed Transactions

Slides:



Advertisements
Similar presentations
Database Systems (資料庫系統)
Advertisements

Unit 9 Concurrency Control. 9-2 Wei-Pang Yang, Information Management, NDHU Content  9.1 Introduction  9.2 Locking Technique  9.3 Optimistic Concurrency.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
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.
TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
Concurrency Control II
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 2: Enforcing Serializable Schedules Professor Chen Li.
Cs4432concurrency control1 CS4432: Database Systems II Lecture #23 Concurrency Control Professor Elke A. Rundensteiner.
Cs4432concurrency control1 CS4432: Database Systems II Lecture #22 Concurrency Control: Locking-based Protocols Professor Elke A. Rundensteiner.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Concurrency Control Chapter 17 Sections
(c) Oded Shmueli Transactions Lecture 1: Introduction (Chapter 1, BHG) Modeling DB Systems.
Quick Review of Apr 29 material
ICS 421 Spring 2010 Transactions & Concurrency Control (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa.
Concurrency Control and Recovery In real life: users access the database concurrently, and systems crash. Concurrent access to the database also improves.
Transaction Management and Concurrency Control
CS 582 / CMPE 481 Distributed Systems Concurrency Control.
Transaction Processing: Concurrency and Serializability 10/4/05.
Transaction Management
Concurrency. Correctness Principle A transaction is atomic -- all or none property. If it executes partly, an invalid state is likely to result. A transaction,
Concurrency Control John Ortiz.
1 Concurrency Control. 2 Transactions A transaction is a list of actions. The actions are reads (written R T (O)) and writes (written W T (O)) of database.
Academic Year 2014 Spring Academic Year 2014 Spring.
Transactions CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
TRANSACTION MANAGEMENT R.SARAVANAKUAMR. S.NAVEEN..
Transactions. What is it? Transaction - a logical unit of database processing Motivation - want consistent change of state in data Transactions developed.
II.I Selected Database Issues: 2 - Transaction ManagementSlide 1/20 1 II. Selected Database Issues Part 2: Transaction Management Lecture 4 Lecturer: Chris.
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.
Fan Qi Database Lab 1, com1 #01-08 CS3223 Tutorial 9.
Timestamp-based Concurrency Control
Multidatabase Transaction Management COP5711. Multidatabase Transaction Management Outline Review - Transaction Processing Multidatabase Transaction Management.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
1 Controlled concurrency Now we start looking at what kind of concurrency we should allow We first look at uncontrolled concurrency and see what happens.
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:
H.Lu/HKUST L06: Concurrency Control & Locking. L06: Concurrency Control & Locking - 2 H.Lu/HKUST Transactions  Concurrent execution of user programs.
CS5204 – Operating Systems 1 Distributed Transactions.
Distributed Transactions What is a transaction? (A sequence of server operations that must be carried out atomically ) ACID properties - what are these.
1 Concurrency Control. 2 Why Have Concurrent Processes? v Better transaction throughput, response time v Done via better utilization of resources: –While.
Database Transaction Abstraction I
Transaction Management
Transaction Management and Concurrency Control
CS422 Principles of Database Systems Concurrency Control
Part- A Transaction Management
Transaction Management
Assignment 2 - Solution   1. w0[x,y,z] c0 r1[x] r2[y] w2[y] r3[z] w3[z] r2[z] w2[y] w1[z] w1[y] c1 c2 c3 a. An equivalent serial history must preserve.
Transaction Management Transparencies
Transaction Management Overview
Transaction Properties
CIS 720 Concurrency Control.
Distributed DBMS Model
Transaction Management
Chapter 10 Transaction Management and Concurrency Control
Lecture 21: Concurrency & Locking
CS162 Operating Systems and Systems Programming Review (II)
Basic Two Phase Locking Protocol
6.830 Lecture 14 Two-phase Locking Recap Optimistic Concurrency Control 10/28/2015.
Distributed Database Management Systems
Distributed Transactions
Lecture 22: Intro to Transactions & Logging IV
Transaction management
Chapter 5: Multiversion Concurrency Control
Transaction Management
Transaction Management Overview
Introduction to Database Systems CSE 444 Lectures 17-18: Concurrency Control November 5-7, 2007.
Database Systems (資料庫系統)
Lecture 18: Concurrency Control
Outline Introduction Background Distributed DBMS Architecture
Transactions, Properties of Transactions
Presentation transcript:

Distributed Transactions Presented By: Mahmoud ElGammal CS 5204 – Fall, 2009

An execution of a program that accesses a shared database. What is a Transaction? An execution of a program that accesses a shared database. Consists of an ordered set of operations that must be executed in sequence. Has to be executed atomically: Each transaction accesses shared data without interfering with other transactions. If a transaction terminates normally, then all of its effects are made permanent; otherwise it has no effect at all. CS 5204 – Fall, 2009

Solution: Concurrency control. The Problem Due to their being non-atomic by nature, concurrent execution of transactions can cause interference. Interference can lead to inconsistency, rendering the DBMS unreliable for data storage! Solution: Concurrency control. The activity of coordinating the actions of processes that operate in parallel, access shared data, and therefore potentially interfere with each other. CS 5204 – Fall, 2009

The Goal of Concurrency Control Maximizing throughput without compromising consistency. Unsupervised concurrency achieves high throughput, but also causes high contention  Consistency is lost. Absence of concurrency achieves consistency, but also eliminates sharing  Worst throughput. We need to find a point in-between where we can achieve: Concurrent execution. Final effect same as some sequential execution. CS 5204 – Fall, 2009

Such executions are called serializable. Serializability The DBMS interleaves the execution of operations from different transactions. It doesn’t (and needn’t) make any promises about the order in which different transactions will execute relative to each other. We can broaden the class of allowable executions to include executions that have the same effect as a serial ones. Such executions are called serializable. Since they have the same effect as serial executions, serializable executions are correct. CS 5204 – Fall, 2009

concurrent execution DB log : Serializability T1 : T2 : T3 : DB is consistent if it is guaranteed to have resulted from any one of: T1 T2 T3 T2 T1 T3 T2 T3 T1 T1 T3 T2 T3 T1 T2 T3 T2 T1 CS 5204 – Fall, 2009

Consider these two transactions: Serializability Consider these two transactions: T1: R1(Z) W1(Y) W1(X) T2: W2(Y) W2(Z) R2(X) Is this execution log serializable? L: R1(Z) W1(Y) W2(Y) W2(Z) R2(X) W1(X) CS 5204 – Fall, 2009

L: R1(Z) W1(Y) W2(Y) W2(Z) R2(X) W1(X) Serializability S1: R1(Z) W1(Y) W1(X) W2(Y) W2(Z) R2(X) L: R1(Z) W1(Y) W2(Y) W2(Z) R2(X) W1(X) S2: W2(Y) W2(Z) R2(X) R1(Z) W1(Y) W1(X) read source conflict last write conflict CS 5204 – Fall, 2009

Each data item has a lock associated with it. Scheduling The DBMS’s scheduler restricts the order in which transactional operations are executed. The goal is to order these operations so that the resulting execution is serializable. Each data item has a lock associated with it. The scheduler utilizes a protocol for executing, rejecting, or delaying an operation according to lock states. Current lock state Lock Request Not locked READ locked WRITE locked READ OK DENY (=defer) WRITE CS 5204 – Fall, 2009

time Two Phase Locking (2PL) 2PL is a locking protocol that guarantees serializability. Consists of three rules: On receiving a conflicting operation, delay the requesting transaction until the requested lock is released then assign the lock to it. A lock is never released until its associated operation is processed. Once the scheduler has released a lock for a transaction, it may not subsequently obtain any more locks for that transaction (on any data item). locking phase release phase Ti time no locks released no new locks requested CS 5204 – Fall, 2009

T1: r1[x]  w1[y]  c1 T2: w2[x]  w2[y]  c2 Two Phase Locking (2PL) Rule (1) prevents two transactions from concurrently accessing a data item in conflicting modes. Rule (2) ensures that the DM processes operations on a data item in the order that the scheduler submits them. Rule (3) guarantees that all pairs of conflicting operations of two transactions are scheduled in the same order. T1: r1[x]  w1[y]  c1 T2: w2[x]  w2[y]  c2 L1: rl1[x] r1[x] ru1[x] wl2[x] w2[x] wl2[y] w2[y] wu2[x] wu2[y] c2 wl1[y] w1[y] wu1[y] c1 L2: rl1[x] r1[x] wl1[y] w1[y] c1 ru1[x] wu1[y] wl2[x] w2[x] wl2[y] w2[y] c2 wu2[x] wu2[y] T2T1 T1T2 CS 5204 – Fall, 2009

T1: w1[x]  w1[y]  c1 T2: w2[y]  w2[x]  c2 Two Phase Locking (2PL) Deadlocks still can happen: T1: w1[x]  w1[y]  c1 T2: w2[y]  w2[x]  c2 L1: wl1[x] w1[x] wl2[y] w2[y] …? The scheduler constructs a waits-for graph (WFG), where deadlocks appear as cycles. To resolve a deadlock, a victim transaction is selected and is forced to abort. T1 T2 CS 5204 – Fall, 2009

Distributed DBMS Model transaction manager physical database transactions …. T data manager DM network TM 1 x1 y1 2 y2 z2 3 x3 z3 CS 5204 – Fall, 2009

Serialization of Distributed Logs Two operations Pj(Ax) and Qi(BY) conflict if all of the following apply: P and Q are not both READ (concurrent READs never conflict) A = B (both access the same record) i != j (they belong to different transactions) X = Y (both appear in the same log) Theorem: Distributed logs are serializable if there exists a total ordering of the transactions such that for conflicting operations Pj and Qi a log shows Pj  Qi only if Tj  Ti CS 5204 – Fall, 2009

Distributed Transaction Processing T1 : WRITE(V); T2 : READ(X); WRITE(Z); T3 : READ(W); WRITE(V); READ(Z); T4: READ(V); READ(Z); V1 X1 DM1 W2 Z2V2 DM2 Z3 V3 DM3 Transactions: Logs:     L1:  R4(V1) W3(V1) R2(X1) W1(V1) L2:  R3(W2) W3(V2) R1(W2) W1(Z2) W1(V2) W2(Z2) L3: R3(Z3) W3(V3) R1(V3) R4(Z3) W1(V3) W2(Z3) Are these logs equivalent to some serial execution of the transactions? CS 5204 – Fall, 2009

Serialization of Distributed Logs Conflict: Pj(AX) and Qi(BY) conflict if (1) P and Q are not both READ, and (2) A = B, and (3) i  j, and (4) X = Y b a L1:  R4(V1) W3(V1) R2(X1) W1(V1) L2:  R3(W2) W3(V2) R1(W2) W1(Z2) W1(V2) W2(Z2) L3: R3(Z3) W3(V3) R1(V3) R4(Z3) W1(V3) W2(Z3) c e d f h g i CS 5204 – Fall, 2009

Serializability Graph R4(V1) → W3(V1) [T4 → T3] R4(V1) → W1(V1) [T4 → T1] W3(V1) → W1(V1) [T3 → T1] W3(V2) → W1(V2) [T3 → T1] W1(Z2) → W2(Z2) [T1 → T2] R3(Z3) → W2(Z3) [T3 → T2] W3(V3) → R1(V3) [T3 → T1] W3(V3) → W1(V3) [T3 → T1] R4(Z3) → W2(Z3) [T4 → T2] T3 T4 T2 T1 Graph is cycle free  Serializable CS 5204 – Fall, 2009