Computer Science Lecture 13, page 1 CS677: Distributed OS Last Class: Canonical Problems Election algorithms –Bully algorithm –Ring algorithm Distributed.

Slides:



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

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.
Concurrency Control II
1 CS 194: Elections, Exclusion and Transactions Scott Shenker and Ion Stoica Computer Science Division Department of Electrical Engineering and Computer.
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.
Chapter 6 Process Synchronization: Part 2. Problems with Semaphores Correct use of semaphore operations may not be easy: –Suppose semaphore variable called.
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Distributed Snapshots –Termination detection Election algorithms –Bully –Ring.
CS 582 / CMPE 481 Distributed Systems Concurrency Control.
Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.
Database management concepts Database Management Systems (DBMS) An example of a database (relational) Database schema (e.g. relational) Data independence.
Transaction Management and Concurrency Control
Synchronization Part 2 REK’s adaptation of Claypool’s adaptation ofTanenbaum’s Distributed Systems Chapter 5 and Silberschatz Chapter 17.
Distributed Systems1 Chapter 7: Distributed Transactions Transaction concepts Centralized/Distributed Transaction Architecture Schedule concepts Locking.
Session - 14 CONCURRENCY CONTROL CONCURRENCY TECHNIQUES Matakuliah: M0184 / Pengolahan Data Distribusi Tahun: 2005 Versi:
Session - 13 CONCURRENCY CONTROL CONCURRENCY TECHNIQUE Matakuliah: M0184 / Pengolahan Data Distribusi Tahun: 2005 Versi:
Synchronization Chapter 5.
Transaction Management
EEC-681/781 Distributed Computing Systems Lecture 12 Wenbing Zhao Cleveland State University.
CS4513 Distributed Computer Systems Synchronization (Ch 5)
Synchronization Chapter 5. Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned.
System Catalogue v Stores data that describes each database v meta-data: – conceptual, logical, physical schema – mapping between schemata – info for query.
Synchronization.
Synchronization Chapter 6 Part III Transactions. –Most of the lecture notes are based on slides by Prof. Jalal Y. Kawash at Univ. of Calgary –Some slides.
TRANSACTIONS AND CONCURRENCY CONTROL Sadhna Kumari.
Concurrency Control in Distributed Databases. By :- Rishikesh Mandvikar rmandvik[at]engr.smu.edu May 1, 2004.
CIS 720 Concurrency Control. Locking Atomic statement –Can be used to perform two or more updates atomically Th1: …. ;……. Th2:…………. ;…….
Solution to Dining Philosophers. Each philosopher I invokes the operations pickup() and putdown() in the following sequence: dp.pickup(i) EAT dp.putdown(i)
Real-Time & MultiMedia Lab Synchronization Chapter 5.
1 Mutual Exclusion: A Centralized Algorithm a)Process 1 asks the coordinator for permission to enter a critical region. Permission is granted b)Process.
Concurrency Control Lectured by, Jesmin Akhter, Assistant professor, IIT, JU.
Concurrency Server accesses data on behalf of client – series of operations is a transaction – transactions are atomic Several clients may invoke transactions.
Global State (1) a)A consistent cut b)An inconsistent cut.
Synchronization Chapter 5. Outline 1.Clock synchronization 2.Logical clocks 3.Global state 4.Election algorithms 5.Mutual exclusion 6.Distributed transactions.
Computer Science Lecture 13, page 1 CS677: Distributed OS Last Class: Canonical Problems Distributed synchronization and mutual exclusion Distributed Transactions.
Computer Science Lecture 13, page 1 CS677: Distributed OS Last Class: Canonical Problems Election algorithms –Bully algorithm –Ring algorithm Distributed.
Synchronization Chapter Contents qClock Synchronization qLogical Clocks qGlobal State qElection Algorithms qMutual Exclusion qDistributed Transactions.
7c.1 Silberschatz, Galvin and Gagne ©2003 Operating System Concepts with Java Module 7c: Atomicity Atomic Transactions Log-based Recovery Checkpoints Concurrent.
Synchronization Chapter 5. Table of Contents Clock Synchronization Logical Clocks Global State Election Algorithms Mutual Exclusion.
Page 1 Concurrency Control Paul Krzyzanowski Distributed Systems Except as otherwise noted, the content of this presentation.
Chapter 20 Transaction Management Thomas Connolly, Carolyn Begg, Database System, A Practical Approach to Design Implementation and Management, 4 th Edition,
Transaction Management Transparencies. ©Pearson Education 2009 Chapter 14 - Objectives Function and importance of transactions. Properties of transactions.
Chapter 5 Synchronization Presenter: Maria Riaz. Distributed Systems – Fall 2004 – Prof. SY Lee2 Sequence of Presentation Synchronization Clock Synchronization.
Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned an earlier time.
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.
Synchronization. Clock Synchronization In a centralized system time is unambiguous. In a distributed system agreement on time is not obvious. When each.
10 1 Chapter 10_B Concurrency Control Database Systems: Design, Implementation, and Management, Rob and Coronel.
Synchronization CSCI 4900/6900. Transactions Protects data and allows processes to access and modify multiple data items as a single atomic transaction.
Synchronization Chapter 5. Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned.
1 Concurrency Control By Ankit Patel. 2 INTRODUCTION Enforcing serializability by locks Locks Locking scheduler Two phase locking Locking systems with.
Lecture on Synchronization Submitted by
Atomic Tranactions. Sunmeet Sethi. Index  Meaning of Atomic transaction.  Transaction model Types of storage. Transaction primitives. Properties of.
Transaction Management
Last Class: Canonical Problems
Transaction Management
Synchronization Chapter 5C
Database management concepts
CIS 720 Concurrency Control.
Concurrency Control II (OCC, MVCC)
Chapter 10 Transaction Management and Concurrency Control
ENFORCING SERIALIZABILITY BY LOCKS
Database management concepts
Introduction of Week 13 Return assignment 11-1 and 3-1-5
Concurrency Control Chapter 17
Chapter 7: Distributed Transactions
Concurrency control (OCC and MVCC)
Presentation transcript:

Computer Science Lecture 13, page 1 CS677: Distributed OS Last Class: Canonical Problems Election algorithms –Bully algorithm –Ring algorithm Distributed synchronization and mutual exclusion

Computer Science Lecture 13, page 2 CS677: Distributed OS Today: More on Transactions Distributed transactions Implementation issues –Workspaces –Writeahead logs Concurrency control –Two phase locks –Time stamps

Computer Science Lecture 13, page 3 CS677: Distributed OS Transaction Primitives Example: airline reservation Begin_transaction if(reserve(NY,Paris)==full) Abort_transaction if(reserve(Paris,Athens)==full)Abort_transaction if(reserve(Athens,Delhi)==full) Abort_transaction End_transaction PrimitiveDescription BEGIN_TRANSACTIONMake the start of a transaction END_TRANSACTIONTerminate the transaction and try to commit ABORT_TRANSACTIONKill the transaction and restore the old values READRead data from a file, a table, or otherwise WRITEWrite data to a file, a table, or otherwise

Computer Science Lecture 13, page 4 CS677: Distributed OS Distributed Transactions a)A nested transaction b)A distributed transaction

Computer Science Lecture 13, page 5 CS677: Distributed OS Implementation: Private Workspace Each transaction get copies of all files, objects Can optimize for reads by not making copies Can optimize for writes by copying only what is required Commit requires making local workspace global

Computer Science Lecture 13, page 6 CS677: Distributed OS Option 2: Write-ahead Logs In-place updates: transaction makes changes directly to all files/objects Write-ahead log: prior to making change, transaction writes to log on stable storage –Transaction ID, block number, original value, new value Force logs on commit If abort, read log records and undo changes [rollback] Log can be used to rerun transaction after failure Both workspaces and logs work for distributed transactions Commit needs to be atomic [will return to this issue in Ch. 7]

Computer Science Lecture 13, page 7 CS677: Distributed OS Writeahead Log Example a) A transaction b) – d) The log before each statement is executed x = 0; y = 0; BEGIN_TRANSACTION; x = x + 1; y = y + 2 x = y * y; END_TRANSACTION; (a) Log [x = 0 / 1] (b) Log [x = 0 / 1] [y = 0/2] (c) Log [x = 0 / 1] [y = 0/2] [x = 1/4] (d)

Computer Science Lecture 13, page 8 CS677: Distributed OS Concurrency Control Goal: Allow several transactions to be executing simultaneously such that –Collection of manipulated data item is left in a consistent state Achieve consistency by ensuring data items are accessed in an specific order –Final result should be same as if each transaction ran sequentially Concurrency control can implemented in a layered fashion

Computer Science Lecture 13, page 9 CS677: Distributed OS Concurrency Control Implementation General organization of managers for handling transactions.

Computer Science Lecture 13, page 10 CS677: Distributed OS Distributed Concurrency Control General organization of managers for handling distributed transactions.

Computer Science Lecture 13, page 11 CS677: Distributed OS Serializability Key idea: properly schedule conflicting operations Conflict possible if at least one operation is write –Read-write conflict –Write-write conflict BEGIN_TRANSACTION x = 0; x = x + 1; END_TRANSACTION (a) BEGIN_TRANSACTION x = 0; x = x + 2; END_TRANSACTION (b) BEGIN_TRANSACTION x = 0; x = x + 3; END_TRANSACTION (c) Schedule 1x = 0; x = x + 1; x = 0; x = x + 2; x = 0; x = x + 3Legal Schedule 2x = 0; x = 0; x = x + 1; x = x + 2; x = 0; x = x + 3;Legal Schedule 3x = 0; x = 0; x = x + 1; x = 0; x = x + 2; x = x + 3;Illegal

Computer Science Lecture 13, page 12 CS677: Distributed OS Optimistic Concurrency Control Transaction does what it wants and validates changes prior to commit –Check if files/objects have been changed by committed transactions since they were opened –Insight: conflicts are rare, so works well most of the time Works well with private workspaces Advantage: –Deadlock free –Maximum parallelism Disadvantage: –Rerun transaction if aborts –Probability of conflict rises substantially at high loads Not used widely

Computer Science Lecture 13, page 13 CS677: Distributed OS Two-phase Locking Widely used concurrency control technique Scheduler acquires all necessary locks in growing phase, releases locks in shrinking phase –Check if operation on data item x conflicts with existing locks If so, delay transaction. If not, grant a lock on x –Never release a lock until data manager finishes operation on x –One a lock is released, no further locks can be granted Problem: deadlock possible –Example: acquiring two locks in different order Distributed 2PL versus centralized 2PL

Computer Science Lecture 13, page 14 CS677: Distributed OS Two-Phase Locking Two-phase locking.

Computer Science Lecture 13, page 15 CS677: Distributed OS Strict Two-Phase Locking Strict two-phase locking.

Computer Science Lecture 13, page 16 CS677: Distributed OS Timestamp-based Concurrency Control Each transaction Ti is given timestamp ts(Ti) If Ti wants to do an operation that conflicts with Tj –Abort Ti if ts(Ti) < ts(Tj) When a transaction aborts, it must restart with a new (larger) time stamp Two values for each data item x –Max-rts(x): max time stamp of a transaction that read x –Max-wts(x): max time stamp of a transaction that wrote x

Computer Science Lecture 13, page 17 CS677: Distributed OS Reads and Writes using Timestamps Read i (x) –If ts(T i ) < max-wts(x) then Abort T i –Else Perform R i (x) Max-rts(x) = max(max-rts(x), ts(T i )) Write i (x) –If ts(T i )<max-rts(x) or ts(T i )<max-wts(x) then Abort T i –Else Perform W i (x) Max-wts(x) = ts(T i )

Computer Science Lecture 13, page 18 CS677: Distributed OS Pessimistic Timestamp Ordering Concurrency control using timestamps.