Distributed Systems Fall 2010 Transactions and concurrency control.

Slides:



Advertisements
Similar presentations
Lecture plan Transaction processing Concurrency control
Advertisements

Optimistic Methods for Concurrency Control By : H.T. Kung & John T. Robinson Presenters: Munawer Saeed.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
Chapter 16 Concurrency. Topics in this Chapter Three Concurrency Problems Locking Deadlock Serializability Isolation Levels Intent Locking Dropping ACID.
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.
University of Tampere, CS Department Distributed Transaction Management Jyrki Nummenmaa
Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Topic 6.3: Transactions and Concurrency Control Hari Uday.
Lock-Based Concurrency Control
Lecture 11 Recoverability. 2 Serializability identifies schedules that maintain database consistency, assuming no transaction fails. Could also examine.
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
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.
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.
Persistent State Service 1 Distributed Object Transactions  Transaction principles  Concurrency control  The two-phase commit protocol  Services for.
Transaction Management
Distributed Systems Fall 2009 Replication Fall 20095DV0203 Outline Group communication Fault-tolerant services –Passive and active replication Highly.
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.
Distributed Systems Fall 2009 Distributed transactions.
Transaction. A transaction is an event which occurs on the database. Generally a transaction reads a value from the database or writes a value to the.
Transactions and concurrency control
Academic Year 2014 Spring Academic Year 2014 Spring.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 16.
Exercises for Chapter 16: Transactions and Concurrency Control
Database Management Systems, 2 nd Edition. R. Ramakrishnan and J. Gehrke1 Transaction Management Overview Chapter 18.
08_Transactions_LECTURE2 DBMSs should guarantee ACID properties (Atomicity, Consistency, Isolation, Durability). This is typically done by guaranteeing.
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 Transactions
Databases Illuminated
1 Transaction Management Overview Chapter Transactions  Concurrent execution of user programs is essential for good DBMS performance.  Because.
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.
Transactions CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
Chapter 15 Concurrency Control Yonsei University 1 st Semester, 2015 Sanghyun Park.
Concurrency Server accesses data on behalf of client – series of operations is a transaction – transactions are atomic Several clients may invoke transactions.
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.
A Survey on Optimistic Concurrency Control CAI Yibo ZHENG Xin
Distributed Transactions Chapter – Vidya Satyanarayanan.
Distributed Processing Systems ( Concurrency Control ) 오 상 규 서강대학교 정보통신 대학원
Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.
Page 1 Concurrency Control Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
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.
IM NTU Distributed Information Systems 2004 Distributed Transactions -- 1 Distributed Transactions Yih-Kuen Tsay Dept. of Information Management National.
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.
TRANSACTION & CONCURRENCY CONTROL 1. CONTENT 2  Transactions & Nested transactions  Methods for concurrency control  Locks  Optimistic concurrency.
NOEA/IT - FEN: Databases/Transactions1 Transactions ACID Concurrency Control.
Lecture 8 Transactions & Concurrency UFCE8K-15-M: Data Management.
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
Switch off your Mobiles Phones or Change Profile to Silent Mode.
Distributed Transactions What is a transaction? (A sequence of server operations that must be carried out atomically ) ACID properties - what are these.
Distributed Databases – Advanced Concepts Chapter 25 in Textbook.
Concurrency Control.
Transaction Properties
Chapter 10 Transaction Management and Concurrency Control
Chapter 15 : Concurrency Control
Distributed Transactions
Transaction management
UNIVERSITAS GUNADARMA
TRANSACTION & CONCURRENCY CONTROL
Presentation transcript:

Distributed Systems Fall 2010 Transactions and concurrency control

Fall 20105DV0203 Outline Transactions –Nested transactions Concurrency control –Locks –Optimistic concurrency control

Fall 20105DV0204 Transactions Set of operations performed as a whole –Begin trans –Perform operations –Commit/abort

ACID Atomicity: “all or nothing” Consistency: transactions take system from one consistent state to another Isolation: transactions do not interfere with each other Durability: committed results of transactions are permanent Fall DV020

Fall 20105DV0206 Problems with transactions Transactions are carried out concurrently for higher performance Problems –Lost update –Inconsistent retrieval Solution –Serial equivalence Conflicting operations

Fall 20105DV0207 Lost update T1: A=read(x), write(x, A*10) T2: B=read(x), write(x, B*10) If not properly isolated, we could get the following interleaving: –A=read(x), B=read(x), write(x, A*10), write(x, B*10) –Executing T1 and T2 should have increased x by ten times twice, but we lost one of the updates

Fall 20105DV0208 Inconsistent retrieval T1: withdraw(x, 10), deposit(y, 10) T2: sum all accounts Improper interleaving: withdraw(x, 10), sum+=read(x), sum+=read(y),..., deposit(y, 10) The sum will be incorrect, since the 10 that were deposited were neither in x nor in y – the retrieval was inconsistent

Fall 20105DV0209 Serial equivalence Serial equivalence: the interleaving of operations is such that the combined effect is the same as if the transactions had been performed (fully) one at a time –Does not mean that we actually perform one transaction at a time, as this would lead to horrible performance

Fall 20105DV02010 Conflicting operations If the result depends on the order of execution, operations are in conflict Read – Read –No conflict Read – Write (or Write – Read) –Conflict! Write – Write –Conflict!

Fall 20105DV02011 Serial equivalence Definition: –For two transactions to be serially equivalent, it is necessary and sufficient that all pairs of conflicting operations of the two transactions be executed in the same order at all of the objects they both access

Fall 20105DV02012 Example (serial equivalence) See Figure in the book © Pearson Education 2005 –Not sequentially consistent Conflicting operations are handled nicely......but in violation of the requirement that all objects must be handled in the same order

Fall 20105DV02013 Aborted transactions Transactions can be aborted for whatever reason –Dirty reads –Premature writes

Fall 20105DV02014 Dirty reads T1 reads a value that T2 wrote, then commits and later, T2 aborts –The value is “dirty”, since the update to it should not have happened –T1 has committed, so it cannot be undone Real world effects

Fall 20105DV02015 Handling dirty reads New rule: let T1 wait until T2 commits/aborts! –But if T2 aborts, we must abort T1...and so on: others may depend on T1 Better rule: –Transactions are only allowed to read objects that committed transactions have written

Fall 20105DV02016 Premature writes “Before images” to recover from bad writes Let x = 50 initially T1: write(x, 10); T2: write(x, 20) Let T1 execute before T2 What happens if either aborts? –Order of commit/abort matters!

Fall 20105DV02017 Handling premature writes If before images are used, delay writes to objects until other transactions that write to the same object have committed/aborted Systems that avoid both dirty reads and premature writes are “strict” –Highly desirable! –Tentative versions (local to each transaction)

Fall 20105DV02018 Nested transactions Tree-structured transactions –Subtransactions at one level may execute concurrently –Subtransactions may provisionally commit or abort independently, and parent may decide whether to abort or not as a result Provisional commit is not a proper commit!

Fall 20105DV02019 Rules for nested transactions A transaction may commit/abort once all child transactions are completed When a subtransaction completes, it makes independent choice whether to provisionally commit or abort

Rules for nested transactions When a parent aborts, so do its children When a subtransaction aborts, the parent may decide what to do If the top-level transaction commits, all subtransactions that have provisionally committed may commit as well Fall DV020

Fall 20105DV02021 Locks Need an object? Get a lock for it! –Read or write locks, or both (exclusive) Two-phase locking –Accumulate locks gradually, then release locks gradually Strict two-phase locking –Accumulate locks gradually, keep them all until completion –Enables “strict” systems Granularity and tradeoffs

Fall 20105DV02022 Shared locks Read locks can be shared Promote read lock to write lock if no other transactions require a lock Requesting a write lock when there are already read locks, or a read lock when there is already a write lock? –Wait until lock is available

Fall 20105DV02023 Locks and nested transactions Isolation –From other sets of nested transactions –From other transactions in own set Rules: –Parents do not run concurrently with children Children can temporarily acquire locks from ancestors –Parent inherits locks when child transactions commit –Locks are discarded if child aborts

Fall 20105DV02024 Deadlocks Typical deadlock: –Transaction A waits for B, transaction B waits for A Deadlocks may arise in long chains Conceptually, construct a wait-for graph –Directed edge between nodes if one waits for the other –Cycles indicate deadlocks Abort transaction(s) as needed

Fall 20105DV02025 Handling deadlock Deadlock prevention –Acquire all locks from the beginning Bad performance Not always possible Deadlock detection –As soon as a lock is requested, check if a deadlock will occur Bad performance: avoid checking always –Must include algorithm for determining which transaction to abort

Fall 20105DV02026 Handling deadlock Lock timeouts –Locks invulnerable for a certain time, then they are vulnerable –Leads to unnecessary aborts Long-running transactions Overloaded system –How to decide useful timeout value?

Fall 20105DV02027 Optimistic concurrency control Optimistic concurrency control assumes problems happen seldom Transaction phases –Working Transaction works with tentative data –Validation Upon completion, see if transaction may commit or must abort –Update Write tentative data from committed transactions to permanent storage

Fall 20105DV02028 Optimistic validation Use conflict rules from earlier! Validate one transaction at a time against others Transactions are numbered (not to be confused with IDs) as they start –Working phase for transaction X is not over until transaction X-1 has completed

Fall 20105DV02029 Backward validation Check read set against write set of transactions that: –were active at the same time as the transaction currently being validated; and –have already committed If overlap is found, then current transaction must be aborted

Fall 20105DV02030 Forward validation Check write set against read set of transactions that: –Are currently active Note that read sets of active transactions may change during validation If overlap is found, we can choose which transaction(s) to abort

Fall 20105DV02031 Comparison of optimistic CC Size of read/write sets –Read sets are usually bigger Choice of transaction to abort –Linked to starvation Overhead –Backward requires old write sets –Forward may need to re-run each time the read set for any active transaction changes

Fall 20105DV02032 Comparison of concurrency control schemes Pessimistic CC –Transactions wait for locks –...and yet, can still be aborted For systems with many CC-related issues –Pessimistic will give a more stable quality of service –Optimistic will abort a large number of transactions and requires substantial work

Fall 20105DV02033 Summary Transactions –ACID –Nested transactions –Problems Lost update Inconsistent retrieval Dirty read Premature writes –Serial equivalence –Strictness

Fall 20105DV02034 Summary Concurrency control –Pessimistic (locks) Deadlocks –Optimistic Backward and forward validation –Comparison of the schemes