© Chinese University, CSE Dept. Distributed Systems / 11 - 1 Distributed Systems Topic 11: Transactions Dr. Michael R. Lyu Computer Science & Engineering.

Slides:



Advertisements
Similar presentations
TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
Advertisements

Lock-Based Concurrency Control
CS542: Topics in Distributed Systems Distributed Transactions and Two Phase Commit Protocol.
Slides for Chapter 13: Distributed transactions
1 CSIS 7102 Spring 2004 Lecture 8: Recovery (overview) Dr. King-Ip Lin.
COS 461 Fall 1997 Transaction Processing u normal systems lose their state when they crash u many applications need better behavior u today’s topic: how.
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
Copyright © George Coulouris, Jean Dollimore, Tim Kindberg This material is made available for private study and for direct.
Jan. 2014Dr. Yangjun Chen ACS Database recovery techniques (Ch. 21, 3 rd ed. – Ch. 19, 4 th and 5 th ed. – Ch. 23, 6 th ed.)
© City University London, Dept. of Computing Distributed Systems / Distributed Systems Session 9: Transactions Christos Kloukinas Dept. of Computing.
Recovery Fall 2006McFadyen Concepts Failures are either: catastrophic to recover one restores the database using a past copy, followed by redoing.
Persistent State Service 1 Distributed Object Transactions  Transaction principles  Concurrency control  The two-phase commit protocol  Services for.
Chapter 19 Database Recovery Techniques. Slide Chapter 19 Outline Databases Recovery 1. Purpose of Database Recovery 2. Types of Failure 3. Transaction.
Chapter 8 : Transaction Management. u Function and importance of transactions. u Properties of transactions. u Concurrency Control – Meaning of serializability.
©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.
Transaction Management WXES 2103 Database. Content What is transaction Transaction properties Transaction management with SQL Transaction log DBMS Transaction.
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.
Academic Year 2014 Spring. MODULE CC3005NI: Advanced Database Systems “DATABASE RECOVERY” (PART – 1) Academic Year 2014 Spring.
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?
1 Module 6 Log Manager COP Log Manager Log knows everything. It is the temporal database –The online durable data are just their current versions.
Distributed Transactions March 15, Transactions What is a Distributed Transaction?  A transaction that involves more than one server  Network.
DISTRIBUTED SYSTEMS II AGREEMENT (2-3 PHASE COM.) Prof Philippas Tsigas Distributed Computing and Systems Research Group.
© Chinese University, CSE Dept. Distributed Systems / Distributed Systems Topic 10: Concurrency Control Dr. Michael R. Lyu Computer Science & Engineering.
Distributed Transactions: Distributed deadlocks Recovery techniques.
Chapter 19 Recovery and Fault Tolerance Copyright © 2008.
Transaction Communications Yi Sun. Outline Transaction ACID Property Distributed transaction Two phase commit protocol Nested transaction.
Distributed Transactions Chapter 13
Lecture 12: Distributed transactions Haibin Zhu, PhD. Assistant Professor Department of Computer Science Nipissing University © 2002.
Distributed Transactions
CSE 486/586 CSE 486/586 Distributed Systems Concurrency Control Steve Ko Computer Sciences and Engineering University at Buffalo.
CSE 486/586, Spring 2013 CSE 486/586 Distributed Systems Concurrency Control Steve Ko Computer Sciences and Engineering University at Buffalo.
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.
Concurrency Control in Database Operating Systems.
Transactions and Concurrency Control Distribuerade Informationssystem, 1DT060, HT 2013 Adapted from, Copyright, Frederik Hermans.
Distributed Transaction Management, Fall 2002Lecture Distributed Commit Protocols Jyrki Nummenmaa
University of Tampere, CS Department Distributed Commit.
Chapter 15 Recovery. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.15-2 Topics in this Chapter Transactions Transaction Recovery System.
Distributed Transactions Chapter – Vidya Satyanarayanan.
Transactions and Concurrency Control. Concurrent Accesses to an Object Multiple threads Atomic operations Thread communication Fairness.
Chapter 10 Recovery System. ACID Properties  Atomicity. Either all operations of the transaction are properly reflected in the database or none are.
From Coulouris, Dollimore, Kindberg and Blair Distributed Systems: Concepts and Design Edition 5, © Addison-Wesley 2012 Slides for Chapter 17: Distributed.
 2002 M. T. Harandi and J. Hou (modified: I. Gupta) Distributed Transactions.
IM NTU Distributed Information Systems 2004 Distributed Transactions -- 1 Distributed Transactions Yih-Kuen Tsay Dept. of Information Management National.
© Chinese University, CSE Dept. Distributed Systems / Distributed Systems Topic 8: Fault Tolerance and Replication Dr. Michael R. Lyu Computer Science.
A client transaction becomes distributed if it invokes operations in several different Servers There are two different ways that distributed transactions.
Recovery technique. Recovery concept Recovery from transactions failure mean data restored to the most recent consistent state just before the time of.
Atomic Tranactions. Sunmeet Sethi. Index  Meaning of Atomic transaction.  Transaction model Types of storage. Transaction primitives. Properties of.
Database recovery techniques
Database Recovery Techniques
Database Recovery Techniques
Department of Computer Engineering
Recovery in Distributed Systems:
Two phase commit.
EEC 688/788 Secure and Dependable Computing
Distributed Systems Topic 7: Transactions and Distributed Transactions
CSE 486/586 Distributed Systems Concurrency Control --- 3
Slides for Chapter 14: Distributed transactions
Database Recovery 1 Purpose of Database Recovery
UNIVERSITAS GUNADARMA
Transactions in Distributed Systems
CSE 486/586 Distributed Systems Concurrency Control --- 3
Transaction Communication
Presentation transcript:

© Chinese University, CSE Dept. Distributed Systems / Distributed Systems Topic 11: Transactions Dr. Michael R. Lyu Computer Science & Engineering Department The Chinese University of Hong Kong

© Chinese University, CSE Dept. Distributed Systems / Outline 1 Motivation 2 Transaction Concepts 3 Two phase Commit 4 Transaction Recovery 5 CORBA Transaction Service 6 Summary

© Chinese University, CSE Dept. Distributed Systems / Motivation  What happens if a failure occurs during modification of resources?  Which operations have been completed?  Which operations have not (and have to be done again)?  In which states will the resources be?

© Chinese University, CSE Dept. Distributed Systems / Transaction Concepts 1 ACID Properties –Atomicity –Consistency –Isolation –Durability 2 Transaction Commit vs. Abort 3 Roles of Distributed Components 4 Flat vs. Nested Transactions

© Chinese University, CSE Dept. Distributed Systems / Atomicity  Transactions are either performed completely or no modification is done.  Start of a transaction is a continuation point to which it can roll back.  End of transaction is next continuation point.

© Chinese University, CSE Dept. Distributed Systems / Consistency  Shared resources should always be consistent.  Inconsistent states occur during transactions: –hidden for concurrent transactions –to be resolved before end of transaction.  Application defines consistency and is responsible for ensuring it is maintained.  Transactions can be aborted if they cannot resolve inconsistencies.

© Chinese University, CSE Dept. Distributed Systems / Isolation  Each transaction accesses resources as if there were no other concurrent transactions.  Modifications of the transaction are not visible to other resources before it finishes.  Modifications of other transactions are not visible during the transaction at all.  Implemented through: –two-phase locking or –optimistic concurrency control.

© Chinese University, CSE Dept. Distributed Systems / Durability  A completed transaction is always persistent (though values may be changed by later transactions).  Modified resources must be held on persistent storage before transaction can complete.  May not just be disk but can include properly battery-backed RAM or the like of EPROMs.

© Chinese University, CSE Dept. Distributed Systems / Transaction Commands  Begin: –Start a new transaction.  Commit: –End a transaction. –Store changes made during transaction. –Make changes accessible to other transactions.  Abort: –End a transaction. –Undo all changes made during the transaction.

© Chinese University, CSE Dept. Distributed Systems / Roles of Components Distributed system components involved in transactions can take role of:  Transactional Client  Transactional Server  Coordinator

© Chinese University, CSE Dept. Distributed Systems / Coordinator  Coordinator plays key role in managing transaction.  Coordinator is the component that handles begin / commit / abort transaction calls.  Coordinator allocates system-wide unique transaction identifier.  Different transactions may have different coordinators.

© Chinese University, CSE Dept. Distributed Systems / Transactional Server  Every component with a resource accessed or modified under transaction control.  Transactional server has to know coordinator.  Transactional server registers its participation in a transaction with the coordinator.  Transactional server has to implement a transaction protocol (two-phase commit).

© Chinese University, CSE Dept. Distributed Systems / Transactional Client  Only sees transactions through the transaction coordinator.  Invokes services from the coordinator to begin, commit and abort transactions.  Implementation of transactions are transparent for the client.  Cannot tell difference between server and transactional server.

© Chinese University, CSE Dept. Distributed Systems / Flat Transactions

© Chinese University, CSE Dept. Distributed Systems / Nested Transactions Main Transaction Call Commit Begin Trans. Begin Trans. Commit Begin Trans. Commit Begin Trans. Commit

© Chinese University, CSE Dept. Distributed Systems / Two-Phase Commit  Multiple autonomous distributed servers: –For a commit, all transactional servers have to be able to commit. –If a single transactional server cannot commit its changes every server has to abort.  Single phase protocol is insufficient.  Two phases are needed: –Phase one: Voting –Phase two: Completion.

© Chinese University, CSE Dept. Distributed Systems / Phase One  Called the voting phase.  Coordinator asks all servers if they are able (and willing) to commit.  Servers reply: –Yes: it will commit if asked, but does not yet know if it is actually going to commit. –No: it immediately aborts its operations.  Hence, servers can unilaterally abort but not unilaterally commit a transaction.

© Chinese University, CSE Dept. Distributed Systems / Phase Two  Called the completion phase.  Co-ordinator collates all votes, including its own, and decides to –commit if everyone voted ‘Yes’. –abort if anyone voted ‘No’.  All voters that voted ‘Yes’ are sent –‘DoCommit’ if transaction is to be committed. –Otherwise ‘Abort'.  Servers acknowledge DoCommit once they have committed.

© Chinese University, CSE Dept. Distributed Systems / Server Uncertainty  Period when a server must be able to commit, but does not yet know if has to..  This period is known as server uncertainty.  Usually short (time needed for coordinator to receive and process votes).  However, failures can lengthen this process, which may cause problems.

© Chinese University, CSE Dept. Distributed Systems / Recovery in Two-Phase Commit  Failures prior to start of 2PC results in abort.  Coordinator failure prior to transmitting commit messages results in abort.  After this point, coordinator will retransmit all commit messages on restart.  If server fails prior to voting, it aborts.  If it fails after voting, it sends GetDecision.  If it fails after committing it (re)sends HaveCommitted message.

© Chinese University, CSE Dept. Distributed Systems / Complexity Assuming N participating servers:  (N-1) Voting requests from coordinator to servers.  (N-1) Votes from servers to coordinator.  At most (N-1) Completion requests from coordinator to servers.  (When commit) (N-1) acknowledgement from servers to coordinator.  Hence, complexity of requests is linear in the number of participating servers.

© Chinese University, CSE Dept. Distributed Systems / Committing Nested Transactions  Cannot use same mechanism to commit nested transactions as: –subtransactions can abort independent of parent. –subtransactions must have made decision to commit or abort before parent transaction.  Top level transaction needs to be able to communicate its decision down to all subtransactions so they may react accordingly.

© Chinese University, CSE Dept. Distributed Systems / Provisional Commit  Subtransactions vote either: –aborted or –provisionally committed.  Abort is handled as normal.  Provisional commit means that coordinator and transactional servers are willing to commit subtransaction but have not yet done so.

© Chinese University, CSE Dept. Distributed Systems / Locking and Provisional Commits  Locks cannot be released after provisional commit.  Data items remain ‘protected’ until top-level transaction commits.  This may reduce concurrency.  Interactions between sibling subtransactions: –should they be prevented as they are different? –allowed as they are part of the same transaction?  Generally they are prevented.

© Chinese University, CSE Dept. Distributed Systems / Transaction Recovery  Recovery concerns data durability (permanent and volatile data) and failure atomicity.  A server keeps data in volatile memory and records committed data in a recovery file.  Recovery manager –save data items in permanent storage –Restore the server’s data items after a crash –reorganize the recovery file for better performance –reclaim storage space (in the recovery file)

© Chinese University, CSE Dept. Distributed Systems / Intentions List  An intentions list of a server is a list of data item names and values altered by a transaction.  The server uses the intentions list when a transaction commits or aborts.  When a server prepares to commit, it must have saved the intentions list in its recovery file.  The recovery files contain sufficient information to ensure the transaction is committed by all the servers.

© Chinese University, CSE Dept. Distributed Systems / Type of entryDescription of contents of entry Object A value of an object Transaction statusTransaction identifier, transaction status (prepared, committed, aborted) and other status values used for two-phase commit Intentions listTransaction identifier and a sequence of intentions, each of which consists of, 4 Entries in Recovery File

© Chinese University, CSE Dept. Distributed Systems / Logging  A log contains history of all the transactions performed by a server.  The recovery file contains a recent snapshot of the values of all the data items in the server followed by a history of transactions.  When a server is prepared to commit, the recover manager appends all the data items in its intentions list to the recovery file.  The recovery manager associates a unique identifier with each data item.

© Chinese University, CSE Dept. Distributed Systems / Log for Banking Service

© Chinese University, CSE Dept. Distributed Systems / Recovery by Logging  Recovery of data items –Recovery manager is responsible for restoring the server’s data items. –The most recent information is at the end of the log. –A recovery manager gets corresponding intentions list from the recovery file.  Reorganizing the recovery file –Checkpointing: the process of writing the current committed values (checkpoint) to a new recovery file. –Can be done periodically or right after recovery.

© Chinese University, CSE Dept. Distributed Systems / Shadow Versions  Shadow versions technique uses a map to locate versions of the server’s data items in a file called a version store.  The versions written by each transaction are shadows of the previous committed versions.  When prepared to commit, any changed data are appended to the version store.  When committing, a new map is made. When complete, new map replaces the old map.

© Chinese University, CSE Dept. Distributed Systems / Shadow Versions Example

© Chinese University, CSE Dept. Distributed Systems / Log and 2PC

© Chinese University, CSE Dept. Distributed Systems / Recovery of 2PC

© Chinese University, CSE Dept. Distributed Systems / CORBA Transaction Service Application Objects CORBA facilities CORBA services Object Request Broker Transaction

© Chinese University, CSE Dept. Distributed Systems / IDL Interfaces Object Transaction Service defined through three IDL interfaces:  Current  Coordinator  Resource

© Chinese University, CSE Dept. Distributed Systems / Current interface Current { void begin() raises (...); void commit (in boolean report_heuristics) raises (NoTransaction, HeuristicMixed, HeuristicHazard); void rollback() raises(NoTransaction); Status get_status(); string get_transaction_name(); Coordinator get_control(); Coordinator suspend(); void resume(in Coordinator which) raises(InvalidControl); };

© Chinese University, CSE Dept. Distributed Systems / Coordinator interface Coordinator { Status get_status(); Status get_parent_status(); Status get_top_level_status(); boolean is_same_transaction(in Coordinator tr); boolean is_related_transaction(in Coordinator tr); RecoveryCoordinator register_resource( in Resource r) raises(Inactive); void register_subtran_aware( in SubtransactionAwareResource r) raises(Inactive, NotSubtransaction);... };

© Chinese University, CSE Dept. Distributed Systems / Resource interface Resource { Vote prepare(); void rollback() raises(...); void commit() raises(...); void commit_one_phase raises(...); void forget(); }; interface SubtransactionAwareResource:Resource { void commit_subtransaction(in Coordinator p); void rollback_subtransaction(); };

© Chinese University, CSE Dept. Distributed Systems / Transaction Example: Funds Transfer (Resource) (Resource) CurrentCoordinator begin() debit() get_control() credit() commit() prepare() register_resource() get_control() register_resource() prepare() commit()

© Chinese University, CSE Dept. Distributed Systems / Summary  Transaction concepts: –ACID –Transaction commands –Roles of distributed components in transactions  Two-phase commit –phase one: voting –phase two: completion  Transaction recovery  CORBA Transaction Service –implements two-phase commit –needs resources that are transaction aware.