Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.

Slides:



Advertisements
Similar presentations
CM20145 Concurrency Control
Advertisements

Optimistic Methods for Concurrency Control By : H.T. Kung & John T. Robinson Presenters: Munawer Saeed.
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.
CS 542: Topics in Distributed Systems Transactions and Concurrency Control.
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
CS6223: Distributed Systems
Lock-Based Concurrency Control
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
1 Supplemental Notes: Practical Aspects of Transactions THIS MATERIAL IS OPTIONAL.
CMPT 401 Summer 2007 Dr. Alexandra Fedorova Lecture X: Transactions.
Database Systems, 8 th Edition Concurrency Control with Time Stamping Methods Assigns global unique time stamp to each transaction Produces explicit.
Exercises for Chapter 17: Distributed Transactions
1 TRANSACTION & CONCURRENCY CONTROL Huỳnh Văn Quốc Phương Thái Thị Thu Thủy
Transactions and concurrency control
Quick Review of Apr 29 material
CMPT Dr. Alexandra Fedorova Lecture X: Transactions.
Distributed Systems 2006 Styles of Client/Server Computing.
©Silberschatz, Korth and Sudarshan16.1Database System Concepts 3 rd Edition Chapter 16: Concurrency Control Lock-Based Protocols Timestamp-Based Protocols.
Distributed Systems Fall 2010 Transactions and concurrency control.
14/06/2015Distribuerede Systemer1 Concurrency Control Thomas Hildebrandt.
CS 582 / CMPE 481 Distributed Systems Concurrency Control.
Quick Review of May 1 material Concurrent Execution and Serializability –inconsistent concurrent schedules –transaction conflicts serializable == conflict.
Transaction Management and Concurrency Control
Transaction Management and Concurrency Control
Persistent State Service 1 Distributed Object Transactions  Transaction principles  Concurrency control  The two-phase commit protocol  Services for.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Chapter 17: Transaction Management
Transaction Management
1 Minggu 8, Pertemuan 15 Transaction Management Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Transactions and concurrency control
Academic Year 2014 Spring Academic Year 2014 Spring.
TRANSACTIONS AND CONCURRENCY CONTROL Sadhna Kumari.
Exercises for Chapter 16: Transactions and Concurrency Control
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 10 Transaction Management.
Transaction Communications Yi Sun. Outline Transaction ACID Property Distributed transaction Two phase commit protocol Nested transaction.
Distributed Systems CS 425 / CSE 424 / ECE 428 Transactions & Concurrency Control  2010, I. Gupta, K. Nahrtstedt, S. Mitra, N. Vaidya, M. T. Harandi,
Distributed Transactions
Databases Illuminated
Transactions CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
Concurrency Server accesses data on behalf of client – series of operations is a transaction – transactions are atomic Several clients may invoke transactions.
TRANSACTION MANAGEMENT R.SARAVANAKUAMR. S.NAVEEN..
Transactions and Concurrency Control Distribuerade Informationssystem, 1DT060, HT 2013 Adapted from, Copyright, Frederik Hermans.
II.I Selected Database Issues: 2 - Transaction ManagementSlide 1/20 1 II. Selected Database Issues Part 2: Transaction Management Lecture 4 Lecturer: Chris.
Distributed Transactions Chapter – Vidya Satyanarayanan.
Distributed Processing Systems ( Concurrency Control ) 오 상 규 서강대학교 정보통신 대학원
Page 1 Concurrency Control Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses are.
Concurrency Control Introduction Lock-Based Protocols
IM NTU Distributed Information Systems 2004 Distributed Transactions -- 1 Distributed Transactions Yih-Kuen Tsay Dept. of Information Management National.
Transaction Management Transparencies. ©Pearson Education 2009 Chapter 14 - Objectives Function and importance of transactions. Properties of transactions.
Timestamp-based Concurrency Control
9 1 Chapter 9_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
Multidatabase Transaction Management COP5711. Multidatabase Transaction Management Outline Review - Transaction Processing Multidatabase Transaction Management.
Lecture 9- Concurrency Control (continued) Advanced Databases Masood Niazi Torshiz Islamic Azad University- Mashhad Branch
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Database Isolation Levels. Reading Database Isolation Levels, lecture notes by Dr. A. Fekete, resentation/AustralianComputer.
18 September 2008CIS 340 # 1 Last Covered (almost)(almost) Variety of middleware mechanisms Gain? Enable n-tier architectures while not necessarily using.
Distributed Transactions What is a transaction? (A sequence of server operations that must be carried out atomically ) ACID properties - what are these.
Chapter 13 Managing Transactions and Concurrency Database Principles: Fundamentals of Design, Implementation, and Management Tenth Edition.
Concurrency Control Techniques
Transaction Management and Concurrency Control
Chapter 10 Transaction Management and Concurrency Control
Distributed Transactions
Transaction management
Exercises for Chapter 14: Distributed Transactions
UNIVERSITAS GUNADARMA
Presentation transcript:

Transactions and Concurrency Control

Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness

Operations of the Account Interface Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Operations of the Branch Interface Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Transactions (on Objects) The basic concept: a sequence of client requests performed as an indivisible unit. Properties: Atomicity, Consistency, Isolation, and Durability. Means to maximize concurrency: serializable interleavings

A Client’s Bank Transaction Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

A Failure Model Writes to permanent storage may fail Processors may crash Messages may be delayed or even lost The faults are assumed to be detectable.

Operations in the Coordinator Interface Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Transaction Life Histories Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

The Lost Update Problem Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

The Inconsistent Retrievals Problem Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Serializable Interleavings Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Serializable Interleavings (cont’d) Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Ensuring Serializability All pairs of conflicting operations of two transactions should be executed in the same order to ensure serializability. (Two operations conflict if their combined effect depends on the order in which they are executed.)

Conflict Rules for Read and Write Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

A Non-Serializable Interleaving Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Recoverability from Aborts Dirty reads Cascading aborts Premature writes Strict executions of transactions Use of tentative versions

A Dirty Read Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Overwriting Uncommitted Values Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Nested Transactions Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Advantages of Nested Transactions Subtransactions at the same level may run concurrently Subtransactions can commit or abort independently

Methods of Concurrency Control Locking: locks are used to order transactions according to the order of arrival of their operations at the same data item Optimistic concurrency control: transactions are allowed to proceed until they are ready to commit, whereupon a check is made to see whether they have performed conflicting operations Timestamp ordering: timestamps are used to order transactions according to their starting times

Exclusive Locks Exclusive locks are a simple serializing mechanism: Two-phase locking: all locks are acquired in the first phase and released in the second Strict two-phase locking: locks are held until the transaction commits or aborts. Granularity is an important issue.

Using Exclusive Locks Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Locking A pair of read operations on the same data item do not conflict. Exclusive locks reduce concurrency more than is necessary. The “many reader/single write” scheme distinguishes two types of lock: read (shared) locks and write locks. Two-phase locking or strict two-phase locking still applies for ensuring serializability.

Lock Compatibility Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Lock Management Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

A Lock Implementation Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

A Lock Implementation (cont’d) Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

A Lock Manager Implementation Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Deadlocks The use of locks may lead to deadlock. Deadlock is a state in which each member of a group of transactions is waiting for some other member to release a lock. A wait-for graph can be used to represent the waiting relationships between concurrent transactions at a server.

A Deadlock Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

A Wait-For Graph Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

A Cycle in a Wait-For Graph Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Another Wait-For Graph Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Deadlock Prevention Techniques Lock (in one atomic step) all data items used by a transaction when it starts. Every transaction requests locks on data items in a predefined order. Each lock is given a limited period, after which it becomes vulnerable.

Deadlock Detection Deadlocks may be detected by finding cycles in the wait-for graph. Two design issues: * Frequency of checking the existence of a cycle * Choice of transactions to be aborted

Resolving a Deadlock Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Increasing Concurrency Two-version locking: allows one transaction to write tentative versions of data items while other transactions read from the committed version of the same data item; read operations wait only if another transaction is currently committing the same data item Hierarchic locks: at each level, the setting of a parent lock has the same effect as setting all the equivalent child locks

Lock Compatibility Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

A Lock Hierarchy Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Compatibility of Hierarchical Locks Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Drawbacks of Locking Overhead of lock maintenance: some locks may be unnecessary Reduced concurrency due to * deadlock prevention * holding locks until the end of a transaction (to avoid cascade aborts) In some applications, the likelihood of conflict is low.

Optimistic Concurrency Control Transactions are allowed to proceed as though there were no possibility of conflict with other transactions until the client issues a CloseTransaction request. When a conflict is detected, some transaction is aborted.

Optimistic Concurrency Control (cont’d) Each transaction has three phases: Read phase: use a tentative version for each updated data item Validation phase: checking if there is a conflict Write phase: if validated, all tentative versions are made permanent

Naive Read/Write Rules Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Validation Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Validation of Transactions For validation purposes, each transaction is assigned (in an ascending order) a transaction number when it enters the validation phase. A transaction always finishes its read phase after all transactions with lower numbers.

Validation of Transactions (cont’d) Validation phases may overlap (but transaction numbers should be assigned sequentially). All write phases are executed sequentially according to their transaction numbers so that there is no need to check write-write conflicts. * Reuse of transaction numbers (as suggested in the book) is not a very good idea.

Validation Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Comparing Backward and Forward Validation Backward: abort the transaction being validated Forward: three options: * defer the validation until the conflicting (and active) transactions have finished * abort all the conflicting active transactions and commit the one being validated * abort the transaction being validated

Comparing Backward and Forward Validation (cont’d) Backward: must retain the write sets of committed transactions that may conflict with active transactions Forward: must allow for new transactions to start during validation Backward: compare a possibly large read set against old write sets Forward: compare a small write set against the read sets of active transactions

Timestamp Ordering Each transaction is assigned a unique timestamp value when it starts. Every operation bears the timestamp of its issuing transaction and is validated when it is carried out. If the operation cannot be validated, then the transaction is aborted immediately.

Read/Write Rules Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Writes and Timestamp Ordering Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Write Rules in Timestamp Ordering Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Reads and Timestamp Ordering Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Read Rules in Timestamp Ordering Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Timestamp Ordering Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Relaxing the Write Rule If a write is too late it can be ignored instead of aborting the transaction, because if it had arrived in time its effects would have been overwritten anyway. However, if another transaction has read the data item, the transaction with the late write fails due to the read timestamp on the item.

Multiversion Timestamp Ordering The server keeps old committed versions as well as tentative versions in its list of versions of data items. With the list, Read operations that arrive too late need not be rejected. A Read operation of a transaction is directed to the version with the largest write timestamp less than the transaction timestamp.

A Late Write Invalidating a Read Source: G. Coulouris et al., Distributed Systems: Concepts and Design, Third Edition.

Comparison