2/22/05 1 9. Queued Transaction Processing CSEP 545 Transaction Processing Philip A. Bernstein Copyright ©2005 Philip A. Bernstein.

Slides:



Advertisements
Similar presentations
Transaction Management: Concurrency Control CS634 Class 17, Apr 7, 2014 Slides based on “Database Management Systems” 3 rd ed, Ramakrishnan and Gehrke.
Advertisements

TRANSACTION PROCESSING SYSTEM ROHIT KHOKHER. TRANSACTION RECOVERY TRANSACTION RECOVERY TRANSACTION STATES SERIALIZABILITY CONFLICT SERIALIZABILITY VIEW.
Dr. Kalpakis CMSC 621, Advanced Operating Systems. Fall 2003 URL: Distributed System Architectures.
RPC Robert Grimm New York University Remote Procedure Calls.
Message Queues COMP3017 Advanced Databases Dr Nicholas Gibbins –
Remote Procedure Call (RPC)
Remote Procedure Call Design issues Implementation RPC programming
(c) Oded Shmueli Transactions Lecture 1: Introduction (Chapter 1, BHG) Modeling DB Systems.
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.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 16 – Intro. to Transactions.
Network Operating Systems Users are aware of multiplicity of machines. Access to resources of various machines is done explicitly by: –Logging into the.
Concurrency Control and Recovery In real life: users access the database concurrently, and systems crash. Concurrent access to the database also improves.
CS 245Notes 101 CS 245: Database System Principles Notes 10: More TP Hector Garcia-Molina.
1 ICS 214B: Transaction Processing and Distributed Data Management Lecture 15: Data Replication with Network Partitions & Transaction Processing Systems.
Software Engineering and Middleware: a Roadmap by Wolfgang Emmerich Ebru Dincel Sahitya Gupta.
Chapter 8 : Transaction Management. u Function and importance of transactions. u Properties of transactions. u Concurrency Control – Meaning of serializability.
The Architecture of Transaction Processing Systems
2/27/ Queued Transaction Processing CSE593 Transaction Processing Philip A. Bernstein Copyright ©1999 Philip A. Bernstein.
16: Distributed Systems1 DISTRIBUTED SYSTEM STRUCTURES NETWORK OPERATING SYSTEMS The users are aware of the physical structure of the network. Each site.
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.
COMP 5138 Relational Database Management Systems Semester 2, 2007 Lecture 8A Transaction Concept.
.NET Mobile Application Development Remote Procedure Call.
TRANSACTION PROCESSING TECHNIQUES BY SON NGUYEN VIJAY RAO.
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.
4/25/ Application Server Issues for the Project CSEP 545 Transaction Processing for E-Commerce Philip A. Bernstein Copyright ©2003 Philip A. Bernstein.
5/21/ Queued Transaction Processing CSEP 545 Transaction Processing Philip A. Bernstein Copyright ©2007 Philip A. Bernstein.
Service Broker Lesson 11. Skills Matrix Service Broker Service Broker, provides a solution to common problems with message delivery and consistency that.
3/6/99 1 Advanced Transaction Models CSE593 - Transaction Processing Philip A. Bernstein.
1 Transactions BUAD/American University Transactions.
Client Server Technologies Middleware Technologies Ganesh Panchanathan Alex Verstak.
Applications and Infrastructure The SQL. Agenda " HW2 Comments " Concluding remarks on Transactions " Summary of Last Class " Transaction Processing Monitor.
Transactions. 421B: Database Systems - Transactions 2 Transaction Processing q Most of the information systems in businesses are transaction based (databases.
CS 245Notes 101 CS 245: Database System Principles Notes 10: More TP Hector Garcia-Molina.
Chapter 15 Recovery. Topics in this Chapter Transactions Transaction Recovery System Recovery Media Recovery Two-Phase Commit SQL Facilities.
5/22/ Business Process Management CSEP 545 Transaction Processing Philip A. Bernstein Copyright ©2007 Philip A. Bernstein.
1 Concurrency Control II: Locking and Isolation Levels.
Distributed Transaction & Long-running transactions Rossen Zhivkov Freelance SharePoint Consultant January 19 th, 2008 Sofia, Bulgaria Krasimir Parushev.
 Remote Procedure Call (RPC) is a high-level model for client-sever communication.  It provides the programmers with a familiar mechanism for building.
Introduction to Database Systems1. 2 Basic Definitions Mini-world Some part of the real world about which data is stored in a database. Data Known facts.
Concurrency Control. Objectives Management of Databases Concurrency Control Database Recovery Database Security Database Administration.
INTRODUCTION TO DBS Database: a collection of data describing the activities of one or more related organizations DBMS: software designed to assist in.
The Relational Model1 Transaction Processing Units of Work.
XA Transactions.
Replication (1). Topics r Why Replication? r System Model r Consistency Models r One approach to consistency management and dealing with failures.
Two-Phase Commit Brad Karp UCL Computer Science CS GZ03 / M th October, 2008.
Transactions. Transaction: Informal Definition A transaction is a piece of code that accesses a shared database such that each transaction accesses shared.
Introduction.  Administration  Simple DBMS  CMPT 454 Topics John Edgar2.
Transaction Management Overview. Transactions Concurrent execution of user programs is essential for good DBMS performance. – Because disk accesses are.
AMQP, Message Broker Babu Ram Dawadi. overview Why MOM architecture? Messaging broker like RabbitMQ in brief RabbitMQ AMQP – What is it ?
Web Services An Introduction Copyright © Curt Hill.
2/28/ Queued Transaction Processing CSE593 Transaction Processing Philip A. Bernstein Copyright ©2001 Philip A. Bernstein.
10 1 Chapter 10 - A Transaction Management Database Systems: Design, Implementation, and Management, Rob and Coronel.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 16 – Intro. to Transactions.
MULTIUSER DATABASES : Concurrency and Transaction Management.
SYSTEMS IMPLEMENTATION TECHNIQUES TRANSACTION PROCESSING DATABASE RECOVERY DATABASE SECURITY CONCURRENCY CONTROL.
1 Concurrency Control. 2 Why Have Concurrent Processes? v Better transaction throughput, response time v Done via better utilization of resources: –While.
Topic 4: Distributed Objects Dr. Ayman Srour Faculty of Applied Engineering and Urban Planning University of Palestine.
6. Application Server Issues for the Project
MQ Series Cross Platform Dominant Messaging sw – 70% of market
CSE 451: Operating Systems Winter 2006 Module 20 Remote Procedure Call (RPC) Ed Lazowska Allen Center
CSE 451: Operating Systems Winter 2004 Module 19 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Introduction of Week 13 Return assignment 11-1 and 3-1-5
CSE 451: Operating Systems Autumn 2009 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Remote Procedure Call Hank Levy 1.
MQ Series Cross Platform Dominant Messaging sw – 70% of market
Remote Procedure Call Hank Levy 1.
CSE 451: Operating Systems Autumn 2010 Module 21 Remote Procedure Call (RPC) Ed Lazowska Allen Center
Remote Procedure Call Hank Levy 1.
CSE 451: Operating Systems Messaging and Remote Procedure Call (RPC)
Presentation transcript:

2/22/ Queued Transaction Processing CSEP 545 Transaction Processing Philip A. Bernstein Copyright ©2005 Philip A. Bernstein

2/22/05 2 Outline 1. Introduction 2. Transactional Semantics 3. Queue Manager Appendices A. Marshaling B. Multi-transaction Requests (workflow) C. (Appendix) Microsoft Message Queue

2/22/ Introduction Direct TP - a client sends a request to a server, waits (synchronously) for the server to run the transaction and possibly return a reply (e.g., RPC) Problems with Direct TP –Server or client-server communications is down when the client wants to send the request –Client or client-server communications is down when the server wants to send the reply –If the server fails, how does the client find out what happened to its outstanding requests? –Load balancing across many servers –Priority-based scheduling of busy servers

2/22/05 4 Persistent Queuing Queuing - controlling work requests by moving them through persistent transactional queues Benefits of queuing –client can send a request to an unavailable server –server can send a reply to an unavailable client –since the queue is persistent, a client can (in principle) find out the state of a request –can dequeue requests based on priority –can have many servers feed off a single queue ClientServer Enqueue Dequeue

2/22/05 5 Other Benefits Queue manager as a protocol gateway –need to support multiple protocols in just one system environment –can be a trusted client of other systems to bridge security barriers Explicit traffic control, without message loss Safe place to do message translation between application formats

2/22/ Transaction Semantics Server View The queue is a transactional resource manager Server dequeues request within a transaction If the transaction aborts, the dequeue is undone, so the request is returned to the queue Start Dequeue(Req, Q1) process request Req Enqueue(Reply, Q2) Commit Client Enqueue Dequeue Server’s request queue Client’s reply queue Server Program Q1 Q2

2/22/05 7 Transaction Semantics Server View (cont’d) Server program is usually a workflow controller It functions as a dispatcher to –get a request, –call the appropriate transaction server, and –return the reply to the client. Abort-count limit and error queue to deal with requests that repeatedly lead to an aborted transaction

2/22/05 8 Client runs one transaction to enqueue a request and a second transaction to dequeue the reply Transaction Semantics - Client View Txn1: Start get input construct request Enqueue(Request, Q1) Commit Txn3: Start Dequeue(Reply, Q2) decode reply process output Commit Q1 Q2 Txn2: Start Dequeue(Req, Q1) process request Req Enqueue(Reply, Q2) Commit

2/22/05 9 Transaction Semantics Client View (cont’d) Client transactions are very light weight Still, every request now requires 3 transactions, two on the client and one on the server –Moreover, if the queue manager is an independent resource manager (rather than being part of the database system), then Transaction 2 requires two phase commit So queuing’s benefits come at a cost

2/22/05 10 Client Recovery If a client times out waiting for a reply, it can determine the state of the request from the queues –request is in Q1, reply is in Q2, or request is executing Assume each request has a globally unique ID If client fails and then recovers, a request could be in one of 4 states: –A. Txn1 didn’t commit – no message in either queue. –B. Txn1 committed but server’s Txn2 did not – request is either in request queue or being processed –C. Txn2 committed but Txn3 did not – reply is in the reply queue –D. Txn3 committed – no message in either queue

2/22/05 11 Client Recovery (2) So, if the client knows the request id R, it can determine state C and maybe state B. What if no queued message has the id R? Could be in state A, B, or D. Can further clarify matters if the client has a local database that can run 2-phase commit with the queue manager –Use the local database to store the state of the request

2/22/05 12 Transaction Semantics - Client View Txn1: Start Get Request R from local DB Enqueue(Request R, Q1) State(R) = “Submitted” Commit Txn3: Start Dequeue(Reply for R, Q2) decode reply & process output State(R) = “Done” Commit Q1 Q2 Txn2: Start Dequeue(Req, Q1) process request Req Enqueue(Reply, Q2) Commit Txn0: Start construct request & store it in local DB State(R) = “NotSubmitted” Commit Not in the textbook

2/22/05 13 Client Recovery (3) If client fails and then recovers, a request R could be in one of 4 states: –A. Txn1 didn’t commit – Local DB says R is NotSubmitted. –B. Txn1 committed but server’s Txn2 did not – Local DB says R is Submitted and R is either in request queue or being processed –C. Txn2 committed but Txn3 did not – Local DB says R is Submitted and R’s reply is in the reply queue –D. Txn3 committed – Local DB says R is Done To distinguish B and C, client first checks request queue (if desired) and then polls reply queue. Not in the textbook

2/22/05 14 Persistent Sessions Suppose client doesn’t have a local database that runs 2PC with the queue manager. The queue manager can help by persistently remembering each client’s last operation, which is returned when the client connects to a queue … amounts to a persistent session

2/22/05 15 Client Recovery with Persistent Sessions // Let R be id of client’s last request // Assume client ran Txn0 for R before Txn1 Client connects to request and reply queues; If (id of last request enqueued  R) { resubmit request } elseif (id of last reply message dequeued  R) { dequeue (and wait for) reply with id R } else // R was fully processed, nothing to recover Now client can figure out A – if last enqueued request is not R D – if last dequeued reply is R B – no evidence of R and not in states A, C, or D.

2/22/05 16 Non-Undoable Operations How to handle non-undoable non-idempotent operations in txn3 ? Txn3: Start Dequeue(Reply for R, Q2) decode reply & process output State(R) = “Done” Commit Crash! => R was processed. But Txn3 aborts. So R is back on Q2. If the operation is undoable, then undo it. If it’s idempotent, it’s safe to repeat it. If it’s neither, it had better be testable.

2/22/05 17 Testable Operations Testable operations –After the operation runs, there is a test operation that the client can execute to tell whether the operation ran –Typically, the non-undoable operation returns a description of the state of the device (before-state) and then changes the state of the device –the test operation returns a description of the state of the device. –E.g., State description can be a unique ticket/check/form number under the print head

2/22/05 18 Recovery Procedure for State C To process a reply 1. Start a transaction 2. Dequeue the reply 3. If there’s an earlier logged device state for this reply and it differs from the current device state, then ask the operator whether to abort this txn 4. Persistently log the current device state with the reply’s ID. This operation is permanent whether or not this transaction commits. 5. Perform the operation on the physical device 6. Commit Log

2/22/05 19 Optimizations In effect, the previous procedure makes the action “process output” idempotent. If “process output” sent a message, it may not be testable, so make sure it’s idempotent! –if txn3 is sending a receipt, label it by the serial number of the request, so it can be sent twice Log device state as part of Dequeue operation (saves an I/O) –i.e., run step 3 before step 2

2/22/ Queue Manager A queue supports most file-oriented operations –create and destroy queue database –create and destroy queue –show and modify queue’s attributes (e.g. security) –open-scan and get-next-element –enqueue and dequeue next element or element identified by index inside or outside a transaction –read element

2/22/05 21 Queue Manager (cont’d) Also has some communication types of operations –start and stop queue –volatile queues (lost in a system failure) –persistent sessions (explained earlier) System management operations –monitor load –report on failures and recoveries

2/22/05 22 Example of Enqueue Parameters (IBM MQSeries) System-generated and application-assigned message Ids Name of destination queue and reply queue (optional) Flag indicating if message is persistent Message type - datagram, request, reply, report Message priority Correlation id to link reply to request Expiry time Application-defined format type and code page (for I18N) Report options - confirm on arrival (when enqueued)?, on delivery (when dequeued)?, on expiry?, on exception?

2/22/05 23 Priority Ordering Prioritize queue elements Dequeue by priority Abort makes strict priority-ordered dequeue too expensive –could never have two elements of different priorities dequeued and uncommitted concurrently But some systems require it for legal reasons –stock trades must be processed in timestamp order

2/22/05 24 Routing Forwarding of messages between queues –transactional, to avoid lost messages –batch forwarding of messages, for better throughput –can be implemented as an ordinary transaction server Often, a lightweight client implementation supports a client queue, –captures messages when client is disconnected, and –forwards them when communication to queue server is re-established Implies system mgmt requirement to display topology of forwarding links

2/22/05 25 State of the Art All app servers support some form of queuing A new trend is to add queuing to the SQL DBMS –Oracle has it. Avoids 2PC for Txn2, allows queries, …. Queuing is hard to build well. It’s a product or major sub-system, not just a feature. Lots of queuing products with small market share. Some major ones are –IBM’s MQSeries –BEA Systems MessageQ –Microsoft Message Queuing

2/22/05 26 Appendix A: Marshaling Caller of Enqueue and Dequeue needs to marshal and unmarshal data into variables Instead, use the automatic marshaling of RPC Here’s how RPC works: App Proxy Runtime StubApp call P return to caller pack argu- ments unpack results send receive send unpack argu- ments pack results P work return wait Client’s SystemServer’s System Call packet Return packet

2/22/05 27 Adapting RPC Marshaling for Queues App Proxy Runtime StubApp call P return to app pack argu- ments unpack results enqueue request dequeue reply dequeue request enqueue reply unpack argu- ments pack results P work return wait Client’s System Server’s System server request queue client reply queue In effect, use queuing as a transport for RPC Example – Queued Component in MSMQ

2/22/05 28 Appendix B: Multi-Transaction Requests Some requests cannot execute as one transaction because –It executes too long (causing lock contention) or –Resources don’t support a compatible 2-phase commit protocol. Transaction may run too long because –It requires display I/O with user –People or machines are unavailable (hotel reservation system, manager who approves the request) –It requires long-running real-world actions (get 2 estimates before settling an insurance claim) Transaction may be required to run independent ACID transactions in subsystems (placing an order, scheduling a shipment, reporting commission)

2/22/05 29 Workflow A multi-transaction request is called a workflow Integrated workflow products are now being offered. –IBM MQSeries Workflow, MS BizTalk Orchestration, TIBCO, JetForm, BEA WebLogic Process Integrator, Action,... –See also They have special features, such as –flowgraph language for describing processes consisting of steps, with preconditions for moving between steps –representation of organizational structure and roles (manual step can be performed by a person in a role, with complex role resolution procedure) –tracing of steps, locating in-flight workflows –ad hoc workflow, integrated with (case mgmt)

2/22/05 30 Managing Workflow with Queues Each workflow step is a request Send the request to the queue of the server that can process the request Server outputs request(s) for the next step(s) of the workflow Submit expense claim Validate claim Get Manager Approval Authorize Payment Request Automatic Deposit notification

2/22/05 31 Workflows Can Violate Atomicity and Isolation Since a workflow runs as many transactions, –it may not be serializable relative to other workflows –it may not be all-or-nothing Consider a money transfer run as 2 txns, T 1 & T 2 –Conflicting money transfers could run between T 1 & T 2 –A failure after T 1 might prevent T 2 from running –These problems require application-specific logic –E.g. T 2 must send ack to T 1 ’s node. If T 1 ’s node times out waiting for the ack, it takes action, possibly compensating for T 1

2/22/05 32 Automated Compensation In a workflow specification, for each step, identify a compensation. Specification is called a saga. If a workflow stops making progress, run compensations for all committed steps, in reverse order (like transaction abort). Need to ensure that each compensation’s input is available (e.g. log it) and that it definitely can run (enforce constraints until workflow completes). Concept is still at the research stage.

2/22/05 33 Pseudo-conversations Simple solution in early TP system products A conversational transaction interacts with its user during its execution This is a sequential workflow between user & server. Since this is long-running, it should run as multiple requests Since there are exactly two participants, just pass the request back and forth –request carries all workflow context –request is recoverable, e.g. send/receive is logged or request is stored in shared disk area This simple mechanism has been superceded by queues and general-purpose workflow systems.

2/22/05 34 Maintaining Workflow State Queue elements and pseudo-conversation requests are places places for persistent workflow state. Other examples: –Browser cookies (files that are read/written by http requests), containing user profile information –Shopping cart (in web server cache or database) Such state management arises within a transaction too –Server scans a file. Each time it hits a relevant record, return it. –Issue: later calls must go to the same server, since only it knows where the transaction’s last call left off. –Sol’n 1: keep state in the message (like pseudo-conversation) –Sol’n 2: first call gets a binding handle to the server, so later calls go to it. Server needs to release state when client disappears

2/22/05 35 Appendix C : Microsoft Message Queuing (MSMQ) Clients enqueue/dequeue to queue servers –API - Open/Close, Send/Receive –Each queue is named in the Active Directory –Additional functions: Create/Delete queue, Locate queue, Set/Get queue properties, Set/Get queue security Send/Receive can be –Transactional on persistent queues (transparently gets transaction context), using DTC –Non-transactional on persistent/volatile queues Independent client has a local persistent queue store. –Processes ops locally, asynchronously sends to a server –Dependent client issues RPC to a queue server (easier to administer, fewer resources required)

2/22/05 36 MSMQ ServersOpen SendRec’v Close API Application1Application2 InformationServerInformationServer Client Proxy Server Server QueueManagerQueueManager ‘A’‘B’‘C’SysSys RoutingServerRoutingServer MSMQ Server Stores messages Dynamic min-cost routing Volatile or persistent (txnal) store and forward Support local / dependent clients and forwarding from servers / independent clients Provides MSMQ Explorer –Topologies, routing, mgmt Security via ACLs, journals, public key authentication

2/22/05 37 MSMQ Interoperation Exchange Connector - Send and receive messages and forms through Exchange Server and MSMQ MAPI transport - Send and receive messages and forms through MAPI and MSMQ Via Level 8 Systems, –Clients - MVS, AS/400, VMS, HP-Unix, Sun-Solaris, AIX, OS/2 clients –Interoperates with IBM MQSeries