Transactional Information Systems:

Slides:



Advertisements
Similar presentations
Two phase commit. Failures in a distributed system Consistency requires agreement among multiple servers –Is transaction X committed? –Have all servers.
Advertisements

1 Transactions and Web Services. 2 Web Environment Web Service activities form a unit of work, but ACID properties are not always appropriate since Web.
6.852: Distributed Algorithms Spring, 2008 Class 7.
(c) Oded Shmueli Distributed Recovery, Lecture 7 (BHG, Chap.7)
CS 603 Handling Failure in Commit February 20, 2002.
Consensus Algorithms Willem Visser RW334. Why do we need consensus? Distributed Databases – Need to know others committed/aborted a transaction to avoid.
ICS 421 Spring 2010 Distributed Transactions Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 3/16/20101Lipyeow.
Distributed DBMSPage © 1998 M. Tamer Özsu & Patrick Valduriez Outline Introduction Background Distributed DBMS Architecture Distributed Database.
1 ICS 214B: Transaction Processing and Distributed Data Management Replication Techniques.
Distributed DBMSPage © 1998 M. Tamer Özsu & Patrick Valduriez Outline Introduction Background Distributed DBMS Architecture Distributed Database.
©Silberschatz, Korth and Sudarshan19.1Database System Concepts Distributed Transactions Transaction may access data at several sites. Each site has a local.
1 ICS 214B: Transaction Processing and Distributed Data Management Distributed Database Systems.
Distributed Systems Fall 2009 Distributed transactions.
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.
Transaction Communications Yi Sun. Outline Transaction ACID Property Distributed transaction Two phase commit protocol Nested transaction.
Distributed Transactions Chapter 13
Distributed Transaction Recovery
Consensus and Its Impossibility in Asynchronous Systems.
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.
Operating Systems Distributed Coordination. Topics –Event Ordering –Mutual Exclusion –Atomicity –Concurrency Control Topics –Event Ordering –Mutual Exclusion.
University of Tampere, CS Department Distributed Commit.
Databases Illuminated
Commit Algorithms Hamid Al-Hamadi CS 5204 November 17, 2009.
Distributed Transactions Chapter – Vidya Satyanarayanan.
Committed:Effects are installed to the database. Aborted:Does not execute to completion and any partial effects on database are erased. Consistent state:
Distributed DBMSPage © 1998 M. Tamer Özsu & Patrick Valduriez Outline Introduction Background Distributed DBMS Architecture Distributed Database.
Fundamentals of Fault-Tolerant Distributed Computing In Asynchronous Environments Paper by Felix C. Gartner Graeme Coakley COEN 317 November 23, 2003.
Distributed Databases – Advanced Concepts Chapter 25 in Textbook.
Transactional Information Systems:
Contents. Goal and Overview. Ingredients. The Page Model.
Recovery in Distributed Systems:
Two Phase Commit CSE593 Transaction Processing Philip A. Bernstein
CPS 512 midterm exam #1, 10/7/2016 Your name please: ___________________ NetID:___________ /60 /40 /10.
Chapter 19: Distributed Databases
Outline Introduction Background Distributed DBMS Architecture
CSC 8320 Advanced Operating Systems Xueting Liao
Transactional Information Systems:
Two phase commit.
Operating System Reliability
Distributed Consensus
Commit Protocols CS60002: Distributed Systems
CS 440 Database Management Systems
RELIABILITY.
Outline Introduction Background Distributed DBMS Architecture
Outline Announcements Fault Tolerance.
2PC Recap Eventual Consistency & Dynamo
2PC Recap Eventual Consistency & Dynamo
EEC 688/788 Secure and Dependable Computing
CSE 486/586 Distributed Systems Concurrency Control --- 3
Assignment 5 - Solution Problem 1
Transactional Information Systems:
Distributed Transactions
EEC 688/788 Secure and Dependable Computing
Causal Consistency and Two-Phase Commit
Brahim Ayari, Abdelmajid Khelil, Neeraj Suri and Eugen Bleim
Distributed Databases Recovery
Chapter 19: Distributed Transaction Recovery
EEC 688/788 Secure and Dependable Computing
EEC 688/788 Secure and Dependable Computing
UNIVERSITAS GUNADARMA
Transactional Information Systems:
EEC 688/788 Secure and Dependable Computing
EEC 688/788 Secure and Dependable Computing
Abstractions for Fault Tolerance
CIS 720 Concurrency Control.
CSE 486/586 Distributed Systems Concurrency Control --- 3
Last Class: Fault Tolerance
Brahim Ayari, Abdelmajid Khelil and Neeraj Suri
Presentation transcript:

Transactional Information Systems: Theory, Algorithms, and the Practice of Concurrency Control and Recovery Gerhard Weikum and Gottfried Vossen © 2002 Morgan Kaufmann ISBN 1-55860-508-8 “Teamwork is essential. It allows you to blame someone else.”(Anonymous) 9/10/2018 Transactional Information Systems

Part IV: Coordination of Distributed Transactions 18 Distributed Concurrency Control 19 Distributed Transaction Recovery 9/10/2018 Transactional Information Systems

Chapter 19: Distributed Transaction Recovery 19.2 Basic Two-Phase Commit Algorithm (2PC) 19.2.1 2PC During Normal Operation 19.2.2 Restart and Termination Protocol 19.2.3 Independent Recovery 19.3 Transaction-Tree Two-Phase Commit 19.4 Optimizations 19.5 Lessons Learned “To marry is to halve your rights and to double your duties.“ (Arthur Schopenhauer) 9/10/2018 Transactional Information Systems

Fundamental Problem of Distributed Commit Transaction operates on multiple servers (resource managers) Global commit needs unanimous local commits of all participants (agents) Distributed system may fail partially (server crashes, network failures) and creates the potential danger of inconsistent decisions Approach: Distributed handshake protocol known as two-phase commit (2PC) with a coordinator taking responsibility for unanimous outcome Recovery considerations for in-doubt transactions 9/10/2018 Transactional Information Systems

Idea: Getting Married over the Web Will you ... ? Will you .. ? Yes! Yes! Married! 9/10/2018 Transactional Information Systems

2PC During Normal Operation First phase (voting): coordinator sends prepare messages to participants and waits for yes or no votes Second phase (decision) coordinator sends commit or rollback messages to participants and waits for acks Participants write prepared log entries in voting phase and become in-doubt (uncertain)  potential blocking danger, breach of local autonomy Participants write commit or rollback log entry in decision phase Coordinator writes begin log entry Coordinator writes commit or rollback log entry and can now give return code to the client´s commit request Coordinator writes end (done, forgotten) log entry to facilitate garbage collection  4n messages, 2n+2 forced log writes, 1 unforced log write with n participants and 1 coordinator 9/10/2018 Transactional Information Systems

Transactional Information Systems Illustration of 2PC Coordinator Participant 1 Participant 2 force-write begin log entry prepared log entry send “prepare” send “yes” commit log entry send “commit” send “ack” write end log entry 9/10/2018 Transactional Information Systems

Statechart for Basic 2PC committed aborted committed1 aborted1 initial collecting forgotten initial1 prepared1 prepare1 / yes1 / sorry1 commit1 / ack1 abort1 commit1 / ack1 abort1 / ack1 committed2 aborted2 initial2 prepared2 prepare2 / yes2 / sorry2 commit2 / ack2 abort2 commit2 / ack2 abort2 / ack2 / prepare1; prepare2 yes1 & yes2 / commit1; sorry1 | sorry2 / abort1; ack1 & ack2 ack1 & ack2 coordinator partici- pant 1 pant 2 9/10/2018 Transactional Information Systems

Restart and Termination Protocol Failure model: process failures: transient server crashes network failures: message losses, message duplications assumption that there are no malicious commission failures  Byzantine agreement no assumptions about network failure handling  can use datagrams or sessions for communication Restart protocol after failure (F transitions): coordinator restarts in last remembered state and resends messages participant restarts in last remembered state and resends message or waits for message from coordinator Termination protocol upon timeout (T transitions): coordinator resends messages and may decide to abort the transaction in first phase participant can unilaterally abort in first phase and wait for or may contact coordinator in second phase 9/10/2018 Transactional Information Systems

Statechart for Basic 2PC with Restart/Termination committed aborted committed1 aborted1 initial collecting forgotten initial1 prepared1 prepare1 / yes1 / sorry1 commit1 / ack1 abort1 commit1 / ack1 abort1 / ack1 committed2 aborted2 initial2 prepared2 prepare2 / yes2 / sorry2 T1|F1 T2|F2 commit2 / ack2 abort2 commit2 / ack2 abort2 / ack2 / prepare1; prepare2 yes1 & yes2 / commit1; sorry1 | sorry2 / abort1; ack1 & ack2 ack1 & ack2 C-pending A-pending T|F coordinator partici- pant 1 pant 2 9/10/2018 Transactional Information Systems

Correctness of Basic 2PC Theorem 19.1 (Safety): 2PC guarantees that if one process is in a final state, then either all processes are in their committed state or all processes are in their aborted state. Proof methodology: Consider the set of possible computation paths starting in global state (initial, initial, ..., initial) and reason about invariants for states on computation paths. Theorem 19.2 (Liveness): For a finite number of failures the 2PC protocol will eventually reach a final global state within a finite number of state transitions. 9/10/2018 Transactional Information Systems

Reinfection of Participants Problem: 2PC assumes that regular work of participants is finished when the commit protocol starts Deferred operations that are triggered at commit time violate this assumption  Prepared participant may become reinfected Solution: Participant that receives request for deferred operation after having prepared itself needs to become prepared again before replying to the requestor of the operation. 9/10/2018 Transactional Information Systems

Transactional Information Systems Independent Recovery Independent recovery: ability of a failed and restarted process to terminate his part of the protocol without communicating to other processes. Theorem 19.3: Under the single-failure assumption it is possible to design a distributed commit protocol so that it can guarantee independent recovery for a failed process. Proof sketch: Avoid global states which have both local commit and abort states in their set of possible global successor states. Coordinator adds willing-to-commit state in between collecting and commit states, and makes T transition from collecting to abort. Participant makes F transition from prepared to abort. 9/10/2018 Transactional Information Systems

Transactional Information Systems Impossibility of Independent Recovery in the Presence of Multiple Failures Theorem 19.4: There exists no distributed commit protocol that can guarantee independent process recovery in the presence of multiple failures (e.g., network partitionings). Proof sketch: Consider two processes, one coordinator and one participant, with computation path G0=(initial, initial), ..., Gm=(committed, committed). Under independent recovery both processes would go into the local aborted states from G0 up to some maximum state G(k-1). In state Gk one of the two processes would independently recovery into its local committed state, but the other one would still behave like in state G(k-1) as a message-based protocol changes the components of the global state one at a time. 9/10/2018 Transactional Information Systems

Chapter 19: Distributed Transaction Recovery 19.2 Basic Two-Phase Commit Algorithm 19.3 Transaction-Tree Two-Phase Commit 19.4 Optimizations 19.5 Lessons Learned 9/10/2018 Transactional Information Systems

Transaction-Tree Hierarchical 2PC During transaction execution the transaction forms a process tree rooted at transaction initiator with bilateral communication links according to request-reply interactions At commit time the process tree can be flattened, provided that all participants are known to the coordinator and that establishing new communication links is inexpensive re-used as it was, using a hierarchical form of 2PC with intermediate nodes being both participants and sub-coordinators restructured to choose a coordinator different from the initiator, considering reliability and speed of processes and the communication topology and protocol  coordinator transfer 9/10/2018 Transactional Information Systems

Flattened vs. Hierarchical Commit Tree Flattened 2PC: communication during transaction execution commit protocol initiator (process0) process3 process1 process2 process4 process5 Hierarchical 2PC: 9/10/2018 Transactional Information Systems

Illustration of Hierarchical 2PC Initiator Process1 prepare yes Process2 Process3 Process4 Process5 commit ack 9/10/2018 Transactional Information Systems

Chapter 19: Distributed Transaction Recovery 19.2 Basic Two-Phase Commit Algorithm 19.3 Transaction-Tree Two-Phase Commit 19.4 Optimizations 19.4.1 Presumed-Abort and Presumed-Commit 19.4.2 Read-only Subtrees 19.4.3 Coordinator Transfer 19.4.4 Reduced Blocking 19.5 Lessons Learned 9/10/2018 Transactional Information Systems

2PC Bottlenecks and Optimizations Goals: reduce the number of messages and forced log writes for higher throughput shorten the critical path until local locks can be released for faster response time reduce the probability of blocking Possible optimizations: fewer messages and forced log writes by presumption in the case of missing information eliminating read-only subtrees as early as possible (dynamic) coordinator transfer protocols with reduced blocking (at expense of more messages) 9/10/2018 Transactional Information Systems

Transactional Information Systems 2PC with Presumption Observation: forcing the begin log entry is usually unnecessary; losing it is never a correctness problem Idea: participants don‘t need to force commit/abort log entry, can inquire coordinator if in doubt if coordinator has already forgotten the transaction, it replies to the inquiry with a presumed result coordinator may even be able to forget transaction without acks from participants Problem: need to ensure that the coordinator‘s presumed result is consistent among two cases of missing information: a) transaction has not yet entered the decision phase (early loser) b) transaction has been decided and garbage collected (forgotten trans.) or needs to be able to discriminate the two cases 9/10/2018 Transactional Information Systems

Illustration of Presumed-Abort Protocol Process 1 prepare Coordinator Process 2 Process 3 force-write prepared yes no abort write rollback Case 1: transaction abort commit Case 2: transaction commit ack end 9/10/2018 Transactional Information Systems

Illustration of Presumed-Commit Protocol Case 1: transaction abort Case 2: transaction commit Process 1 prepare Coordinator Process 2 Process 3 force-write prepared yes no abort rollback begin ack write end commit (force-)write 9/10/2018 Transactional Information Systems

Further Optimizations and Extensions Presumed-commit with non-forced begin log entry: identify list of transaction ids of potential loser transactions (interval of ids minus transactions with commit log entry) by means of non-forced, periodic log entries  can now discriminate forgotten winners from early losers but may be unable to garbage-collect some log entries after failures Co-existence of PA and PC participants in heterogeneous federation (presumed-any protocol): coordinator force-writes log entries so that it can cope with both PA and PC participants coordinator needs to know type of participant (to be included in begin log entry) and sends and expects messages according to participant type 9/10/2018 Transactional Information Systems

Illustration of Presumed-Any Coordinator Presumed-Abort Participant prepare Presumed-Any Coordinator Presumed-Commit force-write prepared yes commit begin ack write end 9/10/2018 Transactional Information Systems

Read-only Subtree Optimization Read-only leaf-node participant votes “read-only” and releases all its locks Read-only intermediate node votes “read-only” when it has received all votes and none of them is “yes” or “no” Coordinator eliminates read-only subtrees from decision phase Read-only optimization more effective for PA than for PC because PC still needs a forced begin log entry. PA can terminate read-only transaction with zero logging cost. Caveat with regard to reinfected participants: If there is a non-zero probability of some participant having to perform deferred operations, none of the read-only participant must release its locks. Otherwise the resulting history could be globally non-serializable. 9/10/2018 Transactional Information Systems

Transactional Information Systems Coordinator Transfer Observations: Transaction initiator is the default coordinator, but often a poor choice Coordinator role may be transferred to other process at initiator‘s commit request (or even later), based on reliability, speed, interconnectivity, and criticality of servers Approaches: Rotate process tree around coordinator as new root, reusing established communication links (e.g., sessions) Linear 2PC with last-agent optimization for linear process chain: transfer coordinator responsibility along linear process chain using “I‘m prepared, you decide” messages 2-party transaction needs only 3 forced log writes and 3 messages Dynamic 2PC: generalizes last-agent optimization to arbitrary trees 9/10/2018 Transactional Information Systems

Initiator- vs. Coordinator-Rooted Process Tree B C E F G H D During transaction execution: During commit protocol: initiator coordinator 9/10/2018 Transactional Information Systems

Illustration of Last-Agent Optimization Process 1 (Initiator) Process 2 Process 3 (Coordinator) force-write prepared “yes / prepare / coordinator transfer” force-write commit “commit” “ack” write end 9/10/2018 Transactional Information Systems

Transactional Information Systems Dynamic 2PC Goal: determine coordinator as quickly as possible (using more messages to compensate for slow branches in the tree) Dynamic 2PC protocol: Nodes in the process tree send prepare messages to all children Leaf nodes that receive a prepare message prepare themselves and send a yes vote to their parent Intermediate nodes that have received yes votes from all but one neighbor prepare themselves and send a yes vote to their last neighbor (generalized last-agent optimization) The process that first receives yes votes from all its neighbors becomes coordinator 9/10/2018 Transactional Information Systems

Illustration of Dynamic 2PC B C E F G D 1: A prepare B, A prepare C 2: B prepare D, B prepare E 3: C prepare F, C prepare G 4: D yes B, E yes B B prepared 5: B yes A A prepared 6: A yes C 7: F yes C, G yes C C becomes coordinator 1 2 3 4 5 6 7 9/10/2018 Transactional Information Systems

Protocols with Reduced Blocking Three-phase commit protocol (3PC): avoid global state with both local abort and local commit in the set of possible global successor states, using three phases: voting, dissemination, decision no blocking under single-failure assumption and still correct in arbitrary failure situations Cooperative termination: in-doubt participants contact other participants rather than waiting for coordinator (needs participant list included in prepare message) Heuristic commit or abort: in-doubt participants on critical servers make unilateral decision upon extra-long timeout, based on type of transaction (e.g., abort for withdrawal) 9/10/2018 Transactional Information Systems

Chapter 19: Distributed Transaction Recovery 19.2 Basic Two-Phase Commit Algorithm 19.3 Transaction-Tree Two-Phase Commit 19.4 Optimizations 19.5 Lessons Learned 9/10/2018 Transactional Information Systems

Transactional Information Systems Lessons Learned 2PC is a fundamental, versatile and standardized, building block for transactional federations including Internet applications Susceptibility to blocking is inherent and the price for consistency Scalability is limited to few participants; asynchronously queued transactions are an alternative, provide atomicity and thus need 2PC, but sacrifice isolation Optimizations aim to reduce forced logging and messages (PA and PC) shorten time until lock release (read-only votes, last-agent optimization, dynamic 2PC) reduce blocking (cooperative termination, 3PC) Coordinator transfer is crucial to avoid dependency on poorly administered initiator or unreliable server (application server is often an appropriate coordinator) 9/10/2018 Transactional Information Systems

Transactional Information Systems A Look Back Part II: Concurrency Control 3 Notions of Correctness PM 4 CC Algorithms 5 Multiversion CC 6 Notions of Correctness OM 7 CC Algorithms on Objects 8 CC on Relational DB 9 CC on Search Structures 10 Impl. & Pragmatic Issues Part III: Recovery 11 Transaction Recovery 12 Crash Recovery Correctness 13 CR Algorithms PM 14 CR Algorithms OM 15 Special Issues of Recovery 16 Media Recovery 17 Application Recovery Part IV: Coordination of Distributed Transactions 18 Distributed CC 19 Distributed Transaction Recovery 9/10/2018 Transactional Information Systems

Transactional Information Systems Take-Away Messages Transactions are an important way of providing execution guarantees Their basic abstraction mechanisms allow for a host of applications to be captured Their fundamental algorithmic approaches center around a few concepts Transactional guarantees have expanded way beyond the database area Session Three – Computer Hardware Chapter Four of Nickerson 9/10/2018 Transactional Information Systems

Transactional Information Systems Outlook Transactions (at least atomicity) on mobile platforms, e.g., following an auction from a car in motion shopping over the cell phone while in a train Transactions involving process executions and web services, e.g., WS-Coordination, including agreement coordination as in 2PC and business activity coordination WS-Transaction and Java Transaction API (JTA) OASIS Business Transactions Protocol Session Three – Computer Hardware Chapter Four of Nickerson 9/10/2018 Transactional Information Systems