Concurrency Control in Distributed Database Systems Intelligent Information Systems Seminar 2 nd Sep 2015 Based on: Philip A. Bernstein and Nathan Goodman.

Slides:



Advertisements
Similar presentations
Concurrency Control WXES 2103 Database. Content Concurrency Problems Concurrency Control Concurrency Control Approaches.
Advertisements

Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Principles of Transaction Management. Outline Transaction concepts & protocols Performance impact of concurrency control Performance tuning.
Concurrency Control II
CSC271 Database Systems Lecture # 32.
(c) Oded Shmueli Transactions Lecture 1: Introduction (Chapter 1, BHG) Modeling DB Systems.
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
1 Chapter 3. Synchronization. STEMPusan National University STEM-PNU 2 Synchronization in Distributed Systems Synchronization in a single machine Same.
Database Systems, 8 th Edition Concurrency Control with Time Stamping Methods Assigns global unique time stamp to each transaction Produces explicit.
Data and Database Administration Chapter 12. Outline What is Concurrency Control? Background Serializability  Locking mechanisms.
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
10 1 Chapter 10 Transaction Management and Concurrency Control Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Transaction Management and Concurrency Control
Transaction Management and Concurrency Control
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
What is a Transaction? Logical unit of work
Transaction Management
1 Transaction Management Database recovery Concurrency control.
1 Minggu 8, Pertemuan 15 Transaction Management Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
9 Chapter 9 Transaction Management and Concurrency Control Hachim Haddouti.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Transaction Management and Concurrency Control
Transactions and Recovery
TRANSACTIONS AND CONCURRENCY CONTROL Sadhna Kumari.
Multi-user Database Processing Architectures Architectures Transactions Transactions Security Security Administration Administration.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
Databases Illuminated
ITEC 3220M Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220m.htm
IDA / ADIT Lecture 9: Transactions and concurrency control Jose M. Peña
Distributed Database Systems Overview
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.
Ch 10: Transaction Management and Concurrent Control.
Concurrency control. Lock-based protocols One way to ensure serializability is to require the data items be accessed in a mutually exclusive manner One.
TRANSACTION MANAGEMENT R.SARAVANAKUAMR. S.NAVEEN..
1 Transactions Chapter Transactions A transaction is: a logical unit of work a sequence of steps to accomplish a single task Can have multiple.
Concurrency Control in Database Operating Systems.
Concurrency Control. Objectives Management of Databases Concurrency Control Database Recovery Database Security Database Administration.
Databases Illuminated
II.I Selected Database Issues: 2 - Transaction ManagementSlide 1/20 1 II. Selected Database Issues Part 2: Transaction Management Lecture 4 Lecturer: Chris.
Computer Science Lecture 13, page 1 CS677: Distributed OS Last Class: Canonical Problems Election algorithms –Bully algorithm –Ring algorithm Distributed.
7c.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Module 7c: Atomicity Atomic Transactions Log-based Recovery Checkpoints Concurrent.
CSC 240 (Blum)1 Database Transactions. CSC 240 (Blum)2 Transaction  A transaction is an interaction between a user (or application) and a database. A.
Transactions and Concurrency Control Fall 2007 Himanshu Bajpai
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses are.
Transaction Management Transparencies. ©Pearson Education 2009 Chapter 14 - Objectives Function and importance of transactions. Properties of transactions.
Introduction to Distributed Databases Yiwei Wu. Introduction A distributed database is a database in which portions of the database are stored on multiple.
Transaction Management and Concurrent Control
9 1 Chapter 9_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
NOEA/IT - FEN: Databases/Transactions1 Transactions ACID Concurrency Control.
Lecture 8 Transactions & Concurrency UFCE8K-15-M: Data Management.
10 1 Chapter 10_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
10 Transaction Management and Concurrency Control MIS 304 Winter 2005.
3 Database Systems: Design, Implementation, and Management CHAPTER 9 Transaction Management and Concurrency Control.
SHUJAZ IBRAHIM CHAYLASY GNOPHANXAY FIT, KMUTNB JANUARY 05, 2010 Distributed Database Systems | Dr.Nawaporn Wisitpongphan | KMUTNB Based on article by :
18 September 2008CIS 340 # 1 Last Covered (almost)(almost) Variety of middleware mechanisms Gain? Enable n-tier architectures while not necessarily using.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
SYSTEMS IMPLEMENTATION TECHNIQUES TRANSACTION PROCESSING DATABASE RECOVERY DATABASE SECURITY CONCURRENCY CONTROL.
Distributed Databases – Advanced Concepts Chapter 25 in Textbook.
Database Transaction Abstraction I
Transaction Management and Concurrency Control
Part- A Transaction Management
Transaction Properties
Chapter 10 Transaction Management and Concurrency Control
Concurrency Control WXES 2103 Database.
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Distributed Transactions
CONCURRENCY Concurrency is the tendency for different tasks to happen at the same time in a system ( mostly interacting with each other ) .   Parallel.
Transactions, Properties of Transactions
Presentation transcript:

Concurrency Control in Distributed Database Systems Intelligent Information Systems Seminar 2 nd Sep 2015 Based on: Philip A. Bernstein and Nathan Goodman. "Concurrency Control in Distributed Database Systems." ACM Computing Surveys (CSUR) 13.2 (1981): Mahdi Jaberzadeh Ansari

Outline 1.Distributed Database Systems o Centralized DBS Vs. Distributed DBS o DDBMS 2.Transaction-Processing Models o Transaction Managers and Data Managers in DDBMS o Two-Phase Commit Algorithm 3.Concurrency Control in DDBMS o Concurrency Control Anomalies o Concurrency Control in DDBMS Vs. Mutual Exclusion in OSs 4.Distributed Synchronization Techniques o Tow-Phase Locking Algorithm o Wound-Wait Locking Algorithm 2IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn

Centralized Multi-User DBS IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn3 Distributed Database Systems DBMS DB

Distributed Multi-User DBS IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn4 Distributed Database Systems DBMS DB DBMS DB DBMS DB DDBS A distributed database system (DDBS) is a collection of multiple, logically interrelated databases distributed over a network.

Distributed Multi-User DBMS IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn5 Distributed Database Systems DBMS DB DBMS DB DBMS DB DDBMS A DDBMS is the software that manages the DDB and provides an access mechanism that makes this distribution transparent to the users.

A Simple Architecture of a DDBMS 6 Transaction Managers (TMs) supervise interactions between users and the DDBMS while Data Managers (DMs) manage the actual database. DB 1 DB 2 DB 3 DM1 DM3 DM2 TM1 TM3 TM2 T1 …. Tn T1 …. Tn T1 …. Tn Four operations are available at each TM interface: o READ(X) o WRITE(X, Val) o BEGIN o END Distributed Transaction-Processing Model IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Distributed Database Systems DDBMS DBMS 1 DBMS 2 DBMS 3

Centralized Transaction-Processing Model A centralized DBMS consists of one TM and one DM executing at one site. 7 DM TM T X T’s Private network dm-write(x) dm-read(x) BEGIN READ(X) WRITE(X, new-value) END TM initializes for T a private network. Sends dm-read(x) if not exists in private network, and returns its value. If X exists in private network rewrites it, otherwise create it with new value. The TM issues dm-write(x) for updated items. DB X X’ IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Transaction-Processing Models

Two-Phase Commit In composed transactions a DBMS can avoid partial results by having property of atomic commitment. Atomic commitment means all of a transaction’s dm-writes are processed or none are. 8 DM TM T X T’s Private network dm-write(X) X’ YY’ DB Y dm-write(Y) Secure Storage Y X END X’X Incorrect Data DB Recovery dm- write(Y) Failed during 2 nd phase dm-write(X) ✓ prewrite(X,Y) IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Transaction-Processing Models Secure Storage is part of the permanent memory which is used to save some partial data or some rows of DB temporally. First Phase Second Phase

Distributed Transaction-Processing Model (1) 9 DM TM T X T’s Private network X’ DB Secure Storage X BEGIN X’ X prewrite(X) dm-write(X) READ(X) dm-read(X) WRITE(X) END DM DB Secure Storage Xi’Xi’ X TM T’ Two-Phase Commit It has to be repeated for each copy of X in all sites. Now assume the commit failed on the second DM. IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Transaction-Processing Models

dm- write(X) Distributed Transaction-Processing Model (2) 10 DM1 TM1 T X T’s Private network X’ DB Secure Storage X’ END DM2 DB Secure Storage Xi’Xi’ X TM2 T’ Slightly modify the prewrites to include all involved DMs. X, DM1 prewrite(X, DM1 ) dm-write(X) X IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Transaction-Processing Models Two-Phase Commit

Concurrency Control Definition Concurrency control is the activity of coordinating concurrent accesses for updates to a database in a multi-user DBMS or DDBMS. The goal is to prevent database updates performed by one user from interfering with database retrievals and updates performed by another one. An algorithm to perform such control in a multi-user DDBMS is called a synchronization technique. 11IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Concurrency Control in DDBMS

Anomalies (1): Lost Update Anomaly 12 Execution of T1Execution of T2 $ 5,000 $ 1,000$ 2,000 $ 4,000 $3,000 Read balance. Sub $1,000.Sub $2,000. Write Result back to DB. Time Bank Lost $1,000. It must be $2,000. In this example 2 users try to update same row of 1 table simultaneously. Tom has an account with 2 ATM cards. Tom at ATM1 wants to withdraw $1,000 in Germany to buy a suit. In a very same time, Tom’s wife which has the second ATM card, wants to withdraw $2,000 in Australia to buy a pair of high heels. IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Concurrency Control in DDBMS

Anomalies (2) : Inconsistent Retrieval Anomaly 13 Execution of T1 Execution of T2 S $2,000 C $500 $ 2,000 $ 1,000 S $1,000 C $500 S $1,000 C $1,500 $ 500 $ 1,500 S $ 1,000 C $500 Ʃ = $1,500 Read saving balance - $1,000 Write result Read Saving and Checking balances Print Sum Read Checking balance + $1,000 Write result Time It must be $2,500 Temporal Result Tom at ATM1 wants to transfer $1,000 from Saving account to his Checking account. A little bit later, Tom’s wife which has the second ATM card, wants to print total amount of money that they have. IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Concurrency Control in DDBMS

Comparison with Mutual Exclusion in OSs (1) Concurrency control in DDBS and mutual exclusion in operating systems are similar in that, both are concerned with controlling concurrent access to shared resources. However, control schemes that work for one, do not necessarily work for the other IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Concurrency Control in DDBMS

Comparison with Mutual Exclusion in OSs (2) Suppose processes P1 and P2 require access to resources R1 and R2 at different points in their execution. 15 Time Execution of P1Execution of P2Resources P1 R1 R2 P2 P1 It is OK in OS concept. However in a database, this execution is not always acceptable. IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Concurrency Control in DDBMS

Comparison with Mutual Exclusion in OSs (3) Assume P1 wants to transfer $1000 from R1 to R2, while P2 wants to print balances and sum of balances must be true. 16 Execution of P1Execution of P2 $ 2,000 R1 $2,000 R2 $500 - $1,000 P1 R1 $1,000 P2 R1 $1,000 R2 $1,500 P1 $ $1,000 $500 $1,000 P2 reads wrong result for R2 balance. Time IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Concurrency Control in DDBMS

Principal Issues in Concurrency Control There are 2 correctness criteria for each concurrency control algorithm: 1)It is expected that each transaction submitted to the system be executed eventually. 2)It is expected the computation performed by each transaction to be the same whether it executes alone in a dedicated system or in parallel with other transactions in a DDBS. 17 DB DM1 T3T2T1 DB DM2 T3T2T1 IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Concurrency Control in DDBMS

Serializability IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn18 Distributed Synchronization Techniques $5000 $2000 DB $5000 $3000 DB $5000 $2500 DB $5000 $2000 DB $5000 $1500 DB $5000 $6700 DB $5000 $4500 DB The order of concurrent transactions is serializable if the result of that be coincide with the result of the one of the possible sterilized orders. The art of finding such order in the partial transactions is called serializability. Serialized orders Concurrency

Two-Phase Locking (1) 19 The Two-Phase Locking (2PL) protocol forces each transaction to make a lock or unlock request in two steps: o Growing Phase: A transaction may obtain locks but may not release any locks. o Shrinking Phase: A transaction may release locks but not obtain any new lock. While the 2PL protocol guarantees serializability, it does not ensure that deadlocks do not happen. In this algorithm local and global deadlock detectors are looking for deadlocks periodically and solve them with restarting transactions to their initial states. IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Distributed Synchronization Techniques

T1 was continuing updating X on DM2 without any knowledge of T2. Now it is time to release all locks. And awake the next queued transaction. Same as before, just form a private network for transaction. If LOCAL X is free then put a Read Lock on It. Keep the lock till END or change to WL. Main approach in 2PL is “Read Any, Write all”. Now just store new value of X in workspace. To update an item, write locks are required on all copies. Two-Phase Locking (2) 20 DM1 TM1 T1 X T’s Private network X’ DB Secure Storage X BEGIN X’ X prewrite(X) dm-write(X) READ(X) dm-read(X) WRITE(X) END DM2 DB Secure Storage Xi’Xi’ TM1 T2 prewrite(X, DM1) X, DM1 Now by having all locks, start to update all copies. dm-write(X) X’ X BEGIN READ(X) T2’s Private network Now in the middle of updating another transaction arisen. dm-write(X) But it must wait, because LOCAL X is lock. IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Distributed Synchronization Techniques

Wound-Wait Locking 21 Wound-Wait locking algorithm follows the same approach as the 2PL protocol. Except it does not have deadlock detector and uses timestamps to prevent deadlock. RequestsT1 isT1 is allowed to t(T1) > t(T2)  YoungerWait for T2(the older one) until it finishes. t(T1) < t(T2)  OlderAbort and rolled back and allowed T2 to be done. Time DB X TM1DM1 TM2 T1 T2 IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn Distributed Synchronization Techniques

Conclusion 1.Distributed Database Systems o Centralized and Distributed Multi-User DBS. o DDB, DDBS, DDBMS. 2.Transaction-Processing Models o Centralized and Distributed Transaction-Processing Models o Transaction Managers(TM) and Data Managers(DM) in DDBMS o 4 Main Operations in a TM Transaction in a DBMS and in a DDBMS: BEGIN, READ, WRITE, END o Modified Two-Phase Commit Algorithm in DDBMS 3.Concurrency Control in DDBMS o Concurrency Control Anomalies Lost Update Anomaly, Inconsistent Retrieval Anomaly o Concurrency Control in DDBMS versus Mutual Exclusion in OSs 4.Distributed Synchronization Techniques o Tow-Phase Locking Algorithm o Wound-Wait Locking Algorithm 22IIS Seminar: Concurrency Control In Distributed DBS Mahdi Jaberzadeh Ansari University of Bonn

23 The End. IIS Seminar: Concurrency Control In Distributed DBMS Mahdi Jaberzadeh Ansari University of Bonn