Transaction Communications Yi Sun. Outline Transaction ACID Property Distributed transaction Two phase commit protocol Nested transaction.

Slides:



Advertisements
Similar presentations
Lecture plan Transaction processing Concurrency control
Advertisements

Topic 6.3: Transactions and Concurrency Control Hari Uday.
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.
CIS 720 Concurrency Control. Timestamp-based concurrency control Assign a timestamp ts(T) to each transaction T. Each data item x has two timestamps:
1 TRANSACTION & CONCURRENCY CONTROL Huỳnh Văn Quốc Phương Thái Thị Thu Thủy
Computer Science Lecture 18, page 1 CS677: Distributed OS Last Class: Fault Tolerance Basic concepts and failure models Failure masking using redundancy.
Quick Review of Apr 29 material
Distributed Systems 2006 Styles of Client/Server Computing.
Distributed Systems Fall 2010 Transactions and concurrency control.
Computer Science Lecture 12, page 1 CS677: Distributed OS Last Class Distributed Snapshots –Termination detection Election algorithms –Bully –Ring.
Transaction Management and Concurrency Control
CS 582 / CMPE 481 Distributed Systems Concurrency Control.
CS 582 / CMPE 481 Distributed Systems
Synchronization. Physical Clocks Solar Physical Clocks Cesium Clocks International Atomic Time Universal Coordinate Time (UTC) Clock Synchronization Algorithms.
Synchronization Part 2 REK’s adaptation of Claypool’s adaptation ofTanenbaum’s Distributed Systems Chapter 5 and Silberschatz Chapter 17.
Transaction Management
Reliability and Partition Types of Failures 1.Node failure 2.Communication line of failure 3.Loss of a message (or transaction) 4.Network partition 5.Any.
©Silberschatz, Korth and Sudarshan19.1Database System Concepts Distributed Transactions Transaction may access data at several sites. Each site has a local.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Transaction Management and Concurrency Control.
Synchronization Chapter 5. Clock Synchronization When each machine has its own clock, an event that occurred after another event may nevertheless be assigned.
CMPT Dr. Alexandra Fedorova Lecture XI: Distributed Transactions.
Distributed Systems Fall 2009 Distributed transactions.
TRANSACTION PROCESSING TECHNIQUES BY SON NGUYEN VIJAY RAO.
CMPT Dr. Alexandra Fedorova Lecture XI: 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
TRANSACTIONS AND CONCURRENCY CONTROL Sadhna Kumari.
Distributed Deadlocks and Transaction Recovery.
Distributed Commit Dr. Yingwu Zhu. Failures in a distributed system Consistency requires agreement among multiple servers – Is transaction X committed?
CS162 Section Lecture 10 Slides based from Lecture and
Distributed Transactions March 15, Transactions What is a Distributed Transaction?  A transaction that involves more than one server  Network.
Chapterb19 Transaction Management Transaction: An action, or series of actions, carried out by a single user or application program, which reads or updates.
Distributed Transactions Chapter 13
Distributed Transactions
Databases Illuminated
PAVANI REDDY KATHURI TRANSACTION COMMUNICATION. OUTLINE 0 P ART I : I NTRODUCTION 0 P ART II : C URRENT R ESEARCH 0 P ART III : F UTURE P OTENTIAL 0 R.
Chapter 15 Recovery. Topics in this Chapter Transactions Transaction Recovery System Recovery Media Recovery Two-Phase Commit SQL Facilities.
Lecture 12 Recoverability and failure. 2 Optimistic Techniques Based on assumption that conflict is rare and more efficient to let transactions proceed.
Transactions CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
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.
Transactions and Concurrency Control Distribuerade Informationssystem, 1DT060, HT 2013 Adapted from, Copyright, Frederik Hermans.
Databases Illuminated
Computer Science Lecture 13, page 1 CS677: Distributed OS Last Class: Canonical Problems Election algorithms –Bully algorithm –Ring algorithm Distributed.
XA Transactions.
Commit Algorithms Hamid Al-Hamadi CS 5204 November 17, 2009.
Distributed Transactions Chapter – Vidya Satyanarayanan.
Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.
Chapter 20 Transaction Management Thomas Connolly, Carolyn Begg, Database System, A Practical Approach to Design Implementation and Management, 4 th Edition,
Transactions. Transaction: Informal Definition A transaction is a piece of code that accesses a shared database such that each transaction accesses shared.
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.
NOEA/IT - FEN: Databases/Transactions1 Transactions ACID Concurrency Control.
Multidatabase Transaction Management COP5711. Multidatabase Transaction Management Outline Review - Transaction Processing Multidatabase Transaction Management.
Distributed Transactions What is a transaction? (A sequence of server operations that must be carried out atomically ) ACID properties - what are these.
Atomic Tranactions. Sunmeet Sethi. Index  Meaning of Atomic transaction.  Transaction model Types of storage. Transaction primitives. Properties of.
Distributed Databases – Advanced Concepts Chapter 25 in Textbook.
Part- A Transaction Management
4.3 Transaction Communication
Transaction Management
Commit Protocols CS60002: Distributed Systems
Chapter 10 Transaction Management and Concurrency Control
Distributed Transactions
Distributed Databases Recovery
UNIVERSITAS GUNADARMA
CIS 720 Concurrency Control.
Transaction Communication
Transactions, Properties of Transactions
Presentation transcript:

Transaction Communications Yi Sun

Outline Transaction ACID Property Distributed transaction Two phase commit protocol Nested transaction

Transaction Service-oriented request/reply communication and multicast communication can be combined as transaction communication. Commonly known as fundamental unit of interaction between client and server processes in a database system. In database, represented by a set of synchronous request/reply operations Atomicity, consistency, isolation, durability properties In communications: set of asynchronous RPC communications with the ACID properties

ACID Properties Transactions are communications with ACID property, ACID mainly concerned with concurrency transparency of distributed system. Atomicity: all or nothing Either all of the operations in a transaction are performed or none of them are, in spite of failures. Consistency: consistent state before transaction => consistent state after Interleaved transaction results in serial execution in some order

ACID Properties (cont.) Isolation: concurrent transactions may not interfere with each other Partial results of an incomplete transaction are not visible to others before the transaction is successfully committed. Durability: after committing, the results are permanent result of a committed transaction is permanent even in case of failures.

Atomicity and Isolation Atomicity = indivisibility != exclusivity Isolation => concurrency control Serializability An initiated transaction is either committed or aborted

Durability Problem: mechanism to allow commits even if hardware or software fails Hardware: stable storage Software: recovery mechanisms Logging Shadow versions

Stable Storage Idea: replication on at least 2 disks, keep one copy “correct” at all times After a crash (or periodical comparison): Both disks identical: you’re in good shape One bad, the other OK (checksums): choose the good one Both seem OK but are different: choose the main disk For durability: write date to stable storage and check regularly Works extremely well in practice

Logging Keep track of all write operations Log old and new values of data in a log-file (in stable storage) Need to keep track of if the changes have been committed On abort: undo all changes (rollback) After crash: redo all changes (roll forward) Need to make undo and redo operations

Shadow Copies Idea: conceptually, copy all files to a private workspace before starting the actual transaction Commit: copy private workspace to stable storage Abort: just delete private workspace Optimizations: Don’t copy files from which data is only read Use shadow blocks instead of shadow files

Concurrency Control Problem: increase efficiency by concurrency Constraint: isolation => (global) serialization Solutions: Two-phase locking Time stamp ordering Optimistic concurrency control

Locking Using locking approach, all shared objects must be locked before they can be accessed and must be released before the end of transaction. Read and write operations only within transactions Locks granted and released only by scheduler Concurrent read / exclusive write locks A shared lock used for reading and exclusive lock used for write Locking policy avoids conflicts between operations

Two-Phase Locking Two phases: First phase: any number of locks can be requested Second phase: once any lock is released no more locks may be granted Problems: Deadlocks? timeouts When should a lock actually be released? Strict two-phase locking

Example on Two-Phase Locking Assume there are three transactions: t0, t1 and t2. Transaction t0 has been committed. t1 and t2 are for concurrent execution. t0: Write A=100, Write B=20 t1: Read A, Read B, 1: Write sum in C, 2: Write diff in D t2: Read A, Read B, 3: Write diff in C, 4: Write sum in D Sche d Interlea ve Log in CLog in DResult (C,D) 2PL 11,2,3,4W1=120 W2=80 W1=80 W2=12 0 (80,120) consistent Feasible 23,4,1,2W1=80 W2=120 W1=12 0 W2=80 (120,80) consistent Feasible 31,3,2,4W1=120 W2=80 W1=80 W2=12 0 (80,120) consistent Not feasible 43,1,4,2W1=80 W2=120 W1=12 0 W2=80 (120,80) consistent Not feasible 51,3,4,2W1=120 W2=80 W1=12 0 W2=80 (80,80) inconsiste nt Not feasible 63,1,2,4W1=80 W2=120 W1=80 W2=12 0 (120,120) Inconsiste nt Not feasible

Timestamp Ordering Idea: A unique timestamp is associated to each transaction Each operation is timestamped with the transaction’s timestamp Schedule operations in the timestamps order If a single operation is rejected, abort

Example on Two-Phase Locking and Timestamp Assume there are three transactions: t0, t1 and t2. Transaction t0 has been committed. t1 and t2 are for concurrent execution. t0: Write A=100, Write B=20 t1: Read A, Read B, 1: Write sum in C, 2: Write diff in D t2: Read A, Read B, 3: Write diff in C, 4: Write sum in D Sche d Interle ave Log in CLog in D Result (C,D) Timesta mp 2PL 11,2,3,4W1=120 W2=80 W1=80 W2=12 0 (80,120) consisten t Feasible 23,4,1,2W1=80 W2=120 W1=12 0 W2=80 (120,80) consisten t t1 aborts, restarts Feasible 31,3,2,4W1=120 W2=80 W1=80 W2=12 0 (80,120) consisten t FeasibleNot feasible 43,1,4,2W1=80 W2=120 W1=12 0 W2=80 (120,80) consisten t t1 aborts, restarts Not feasible 51,3,4,2W1=120 W2=80 W1=12 0 W2=80 (80,80) inconsiste nt cascade aborts Not feasible 63,1,2,4W1=80 W2=120 W1=80 W2=12 0 (120,120) inconsiste nt t1 aborts, restarts Not feasible

Optimistic Concurrency Control Hypothesis: conflicts are unlikely Also some real-time requirement Method: Allow transaction complete and then validate before making effect permanent Work on shadow copies If validation of changes then commit, else abort

Distributed Transaction One coordinator (usually the initiator of the transaction) and several participating processes (remote process) At commit Atomicity: either all nodes commit or none do Isolation: effects of the transaction not made visible until all nodes have made an irrevocable decision to commit or abort

Two Phase Commit Protocol ACID properties can be achieved by the two-phase commit(2PC) protocol. There is one coordinator and multiple participants. Each of them have access to some stable storage. Activity log is maintained in the stable storage. Coordinator: 1. Prepare to commit the transaction by writing every update in activity log. 2. Write a precommit message in the activity log. Send a voting message to all participants asking whether they are ready to commit. 3. If all participants vote yes within the time-out period, multicast a commit message. Otherwise, multicast an abort message.

Two Phase Commit Protocol (cont.) Participant: 1. Prepare to commit the transaction by writing every update in activity log. 2. Write a precommit message in the activity log. Wait for request to vote from coordinator. 3. When receiving a vote request, test whether the transaction can be committed and if yes, writes a precommit to its activity log and sends a YES reply, otherwise send a NO reply. 4. Wait for commit message from the coordinator. If received, commit the transaction. If abort message is received, abort the transaction.

Two Phase Commit Protocol (Recovery) Coordinator : 1. If the processor crashes, it will check the activity log for the transaction. 2. If the precommit message is not in the log, abort the transaction (failure before precommit). 3. If the commit message is not in the log, retake the vote (failure after precommit and before commit). 4. If the commit message is there in the log, finish the transaction (failure after commit).

Failure Resistance of Two Phase Commit Use reliable communications (RPC) Participant failures detected by coordinator If coordinator fails: Participant nodes that voted for commit will timeout Unavoidable uncertainty period Can be reduced through three phase commit or by allowing participants to contact each other Put the coordinator on a reliable machine

Nested Transaction Definition: nested transaction = tree of transactions Commit of a subtransaction takes place only if parent transaction commits Rollback of a transaction forces rollback of all its subtransactions

Rules for Nested Transactions Commit rule Commit of a transaction makes it result accessible only to its parent Final global commit happens only if local and all ancestors commit Rollback rule If a transaction is rolled back, all its subtransactions are also rolled back (whatever their status)

Rules for Nested Transaction (cont’d) Visibility rule All changes by a subtransaction are visible to parent upon local commit All objects held by parent are visible to subtransactions Locking rule Externally, toplevel transaction holds all locks Internally, multiple transactions may hold exclusive locks Only leaf transactions may operate on locked objects Lock inheritance

Final Remarks on Transactions First introduced for database requirements Very high reliability High throughput => concurrency Data characteristics: huge volumes, fine graularity Search expressed by simple languages Used as building blocks for more general distributed environments

References Distributed Operating Systems & Algorithms, by Randy Chow and Theodore Johnson, 1997 Towards a Transport Service for Transaction Processing Applications, Network Working Group UCLA, R. Braden htm