UNIT IV – CLIENT SERVER TRANSACTION PROCESSINGINTRODUCTION ACID properties. ACID is an acronym for atomicity, consistency, isolation, and durability. Flat transactions represent the simplest type of transaction, and for almost all existing systems, it is the only one that is supported at the application programming level. A flat transaction is the basic building block for organizing an application into atomic actions. A nested transaction is used to provide a transactional guarantee for a subset of operations performed within the scope of a larger transaction. Doing this allows you to commit and abort the subset of operations independently of the larger transaction. TP(Transaction Processing) Monitors specialize in managing transactions from their point of origin-typically on the client-across one or more servers and then back to the originating client. When a transaction ends, the TP monitor ensures that all the systems involved in the transaction are left in a consistent state. TP Monitors provide an OS-on top of the existing OS’s that connects in real time these 1000 of impatient humans with a pool of shared server’s processes-this is called funneling. Conventional and RPC transactions usually involve a human user that requires immediate attention; they run in high-priority mode. Publish-and-Subscribe transaction runs as high priority messages too. Batch transactions run in low priority mode. MOM -based Queued transaction can be of either type. TP-Lite is simply the integration of TP Monitor functions in the database engines. TP-Heavy is TP Monitors which supports the Client/Server architecture and allow PC to initiate some very complex multi server transaction from the desktop. 1 CONTENTS ACID properties When a transaction processing system creates a transaction, it will ensure that the transaction will have certain characteristics. The developers of the components that comprise the transaction are assured that these characteristics are in place. They do not need to manage these characteristics themselves. These characteristics are known as the ACID properties. ACID is an acronym for atomicity, consistency, isolation, and durability. 1. Atomicity The atomicity property identifies that the transaction is atomic. An atomic transaction is either fully completed, or is not begun at all. Any updates that a transaction might affect on a system are completed in their entirety. If for any reason an error occurs and the transaction is unable to complete all of its steps, the then system is returned to the state it was in before the transaction was started. An example of an atomic transaction is an account transfer transaction. The money is removed from account A then placed into account B. If the system fails after removing the money from account A, then the transaction processing system will put the money back into account A, thus returning the system to its original state. This is known as a rollback, as we said at the beginning of this chapter.. 2. Consistency A transaction enforces consistency in the system state by ensuring that at the end of any transaction the system is in a valid state. If the transaction completes successfully, then all changes to the system will have been properly made, and the system will be in a valid state. If any error occurs in a transaction, then any changes already made will be automatically rolled back. This will return the system to its state before the transaction was started. Since the system was in a consistent state when the transaction was started, it will once again be in a consistent state. 2 it could access data from the system that may not be consistent. and the system back in a consistent state. The models are: Flat Transaction 3 . it appears to be the only action that the system is carrying out at one time. all of the changes it made to the system are permanent. regardless of what happens to the system later on. This is important in that as the transaction is being executed. If a transaction was not running in isolation. By logging the steps that the transaction performs. the total will again be what it should be. Isolation When a transaction runs in isolation. By rolling back the removal from account A.Looking again at the account transfer system. There are safeguards that will prevent the loss of information. By providing transaction isolation. Transaction Models This topic describes the relationship between the transaction programming models. this is prevented from happening. The system would no longer be consistent. If there are two transactions that are both performing the same function and are running at the same time. transaction isolation will ensure that each transaction thinks it has exclusive use of the system. even in the case of system failure. The concept of durability allows the developer to know that a completed transaction is a permanent part of the system. then the total in all accounts would have changed. this may not be the case. Durability A transaction is durable in that once it has been successfully completed. the system is consistent if the total of all accounts is constant. the state of the system can be recreated even if the hardware itself has failed. The transaction ensures that the system remains consistent after the transaction ends. If an error occurs and the money is removed from account A and not added to account B. the state of the system may not be consistent. but during an individual transaction. 4. 3. and so forth. it is the only one that is supported at the application programming level. in turn. Distributed Flat Transaction Nested Transaction (i) Flat Transaction Flat transactions represent the simplest type of transaction. if necessary. reentrancy. The major restriction of flat transactions is that there is no way of either committing or aborting parts of such transactions. and quasi-reentrancy 4 . It can contain an arbitrary number of simple actions: these actions may. Its an all or nothing preposition there’s no way to commit or abort parts of a flat transaction. or committing results in several steps. be either protected. Reusability. These transactions are called flat because there is only one layer of control by the application. real. Putting a flat transaction as an execution unit around a sequence of either protected or real actions makes the whole appear as indivisible as far as the application is concerned. and for almost all existing systems. The transaction starts with begin_transaction and ends with commit_transaction ot abort_transaction. A flat transaction is the basic building block for organizing an application into atomic actions. or even unprotected. Consistency is a necessary characteristic of any computer application and at least partly depends on the program design and code. Each site’s TP monitor must manage its local piece of the transaction. the TP monitor coordinates the transactions with the local ACID subsystem and resource managers. Data store managers should ensure that the order of record insertions does not influence their effect on the data store. Within a site. persistent objects and message transports. the insertion of record A followed by the insertion of record B should have the same effect as the insertion of record B followed by the insertion of record A.including database managers. This must run independently of the transaction processing system and while the data being recovered is offline from the transaction processing system. This is all done using Two-phas commit protocol. Two Phase Commit Protocol 5 . queue managers. Durability of transactions requires a data store forward recovery facility. Back-to-Back Transaction Limitations of Flat Transaction Compound business transactions that need to be partially rolled back Business transactions with humans in the loop Business transactions that span long periods of time Business transactions with a lot of bulk Business transactions that span across companies or the Internet (ii) Distributed Flat Transaction The transaction must travel across multiple sites to get to the resources it needs. which coordinates the transaction’s commit or abort across multiple sites.are variously used to guarantee that the same code is executed in every invocation of a transaction. doAbort(trans) Call from coordinator to participant to tell participant to abort its part of a transaction. Before voting Yes. participant) Call from participant to coordinator to confirm that it has committed the transaction. Participants that voted Yes are waiting for a doCommit or doAbort request from the coordinator. getDecision(trans) → Yes / No 6 . (b)Otherwise the coordinator decides to abort the transaction and sends doAbort requests to all participants that voted Yes. it prepares to commit by saving objects in permanent storage. haveCommitted(trans. 4. 2. doCommit(trans) Call from coordinator to participant to tell participant to commit its part of a transaction. Participant replies with its vote. Phase 2 3.Phase 1 1. The coordinator sends a canCommit? request to each of the participants in the transaction. When a participant receives one of these messages it acts accordingly and in the case of commit. If the vote is No the participant aborts immediately. Operations for two-phase commit protocol canCommit?(trans)→ Yes / No Call from coordinator to participant to ask whether it can commit a transaction. The coordinator collects the votes (including its own). makes a haveCommitted call as confirmation to the coordinator. When a participant receives a canCommit? request it replies with its vote (Yes or No) to the coordinator. (a)If there are no failures and all the votes are Yes the coordinator decides to commit the transaction and sends a doCommit request to each of the participants. are still hidden to all other transactions until the parent also commits. That is. of course. Committing a nested transaction has no effect on the state of the parent transaction. Those modifications. the child transactions are resolved in the same way as the parent. If the parent transaction commits or aborts while it has active children. Used to recover from server crash or delayed messages. Hazard Windows (iii) Nested Transactions A nested transaction is used to provide a transactional guarantee for a subset of operations performed within the scope of a larger transaction. Likewise. The only result of the abort is that neither the parent nor any other transactions will see any of the database modifications performed under the protection of the nested transaction. then 7 . aborting the nested transaction has no effect on the state of the parent transaction. However. Doing this allows you to commit and abort the subset of operations independently of the larger transaction. Performance Overhead 2. If the parent commits.Call from participant to coordinator to ask for the decision on a transaction after it has voted Yes but has still had no reply after some delay. then the child transactions abort as well. the parent transaction may not perform any operations other than to commit or abort. or to create more child transactions. The parent transaction is still uncommitted. Limitations of Two-Phase Commit protocol 1. the parent transaction can now see any modifications made by the child transaction. if the parent aborts. The rules to the usage of a nested transaction are as follows: While the nested (child) transaction is active. Isolation d. Consistency c. Consistency. ACID stands for a. Durability 2. Durability d. Availability. they are now held by the parent transaction until such a time as that parent commits. Durability c. Atomicity b. Atomicity. The depth of the nesting that you can achieve with nested transaction is limited only by memory. whatever modifications have been performed by the child transactions are also committed. Isolation. Objective Type Questions 1. Isolation. Consistency. Atomicity. Durability 8 . Availability. Which property identifies that the transaction is atomic? a. Durability b. Rather. Concurrency. Any database modifications performed by the nested transaction are not visible outside of the larger encompassing transaction until such a time as that parent transaction is committed. Isolation. The locks held by a nested transaction are not released when that transaction commits. Concurrency. Isolation. Flat transaction b.3. Durability 8. Nested transaction d. If the transaction has been successfully completed. In which property. Isolation d. Which transaction that span long periods of time? a. Distributed Flat transaction 6. The transaction must travel across multiple sites to get to the resources it needs is called a. all of the changes it made to the system are permanent is called a. it must leave the system in a correct state or it must abort? a. Nested transaction d. Atomicity b. after a transaction executes. A transaction is used to provide a transactional guarantee for a subset of operations performed within the scope of a larger transaction is called a. Nested transaction d. Consistency c. Distributed Flat transaction 7. Distributed Flat transaction 5. Distributed transaction c. Durability 4. Consistency c. Atomicity b. Isolation d. The changes that a transaction makes to shared resources must not become visible outside the transaction until it commits is called 9 . Distributed transaction c. Flat transaction b. Flat transaction b. Distributed transaction c. 2. When a transaction ends. TP Monitors know how to run transactions. 3. A TP monitor can manage resources on a single server or multiple servers. Atomicity b. and Durability. nested transaction. In addition. Isolation d. Define Atomicity. Client/Server Communications Management 10 . What is meant by flat transaction. Process management 2. Define transaction. 4. and it can cooperate with other TP Monitors in federated arrangements. load-balances their execution. Transaction Management 3. Distributed flat transaction. Big Questions 1. Durability Review Questions Two Mark Questions 1. the TP monitor ensures that all the systems involved in the transaction are left in a consistent state. Define ACID property. Explain in detail the various transaction models. TP Monitor TP (Transaction Processing) Monitors specialize in managing transactions from their point of origin-typically on the client-across one or more servers and then back to the originating client. It also provides a framework for running middle-tier server applications and components. Consistency. a. Consistency c. A TP monitor does three things: 1. Isolation. It provides services that are required for OLTP applications. and restart then after failures. route them across systems. The TP Monitor assigns the execution of the dynamic library functions to server classes.(i) TP Monitors and OS TP Monitors were introduced to run classes of applications that could service 100 and sometimes 1000 of clients. the TP Monitor hands it to an available process in the server class pool. oversees its execution.typically a communication connection. The “funneling act”is part of what a TP Monitor must do to manage the server side of a user-written OLTP application. invokes it. TP Monitors provide an OS-on top of the existing OS’s that connects in real time these 1000 of impatient humans with a pool of shared server’s processes-this is called funneling. half a MB of memory. Each application can have one or more server classes. The operating system keeps 11 . After that completes. The TP Monitor balances the workload between them. The server side of the OLTP application is typically packaged as a dynamic library that contains a number of related functions. 1 or 2 processors. the server process can be reused by another client. When a client needs a service request. The server process dynamically links to the DLL function called by the client. which are pools of pre-started application processes or threads. and a dozen open file handles. waiting for work. If each of these 1000 of clients were given all the resources it needed on a server. Each process or thread in a server class is capable of doing the work. and returns the results to the client. conversational. The job of a TP Monitor is to guarantee the ACID properties while maintaining high transaction throughput. The unit of management. load-balancing. These applications had to be bullet-proof and highly reliable if they were going to serve thousands of users in mission- critical situations. and the 12 . We can also partition server classes by application type. most TP Monitors let us manually control how many processes or threads are available to each process class. The TP Monitor does that by running some high-priority server classes and dynamically assigning them to the VIP clients. desire response time. it must manage the execution. (ii) TP Monitors and Transaction Management The transaction discipline was introduced in the early TP Monitors to ensure the robustness of multi-user applications that ran on the servers. Typically. TP Monitors were developed from the ground up as operating systems for transactions.the already loaded dynamic libraries in memory. If the number of incoming client requests exceeds the number of processes in a server class. Batch and low-priority functions are assigned to low-priority server classes. failures. fault-tolerance requirements. and client/server interaction modes— including queued. and synchronization of transaction workloads. broken connections. The more sophisticated TP Monitors can distribute the process load across multiple CPUs in SMP or MPP environments. In addition to providing dynamic load- balancing. short-running and high-priority functions are packaged in high-priority server classes. the application programmers do not have to concern themselves with issues like concurrency. the resource they manage. the TP Monitor may dynamically start new ones—this is called load-balancing. where they can be shared across processes. the TP Monitor removes the process-per-client requirement by funneling incoming client requests to shared server processes. To do that. With TP Monitors. Part of the load-balancing act involves managing the priorities of the incoming requests. or RPC. In essence. and recovery was the ordinary transaction and the programs that invoked them. execution. distribution. Publish-and-Subscribe transaction runs as high priority messages too.synchronization of resources across multiple nodes. (iii) TP Monitor and Client/server Interaction Types The types are: Conventional transaction RPC transaction Queued transaction Publish-and-Subscribe transaction Batch transaction Conventional and RPC transactions usually involve a human user that requires immediate attention. Feature Non-Transactional Non-Transactional Communications Communications Participants Loosely coupled client/server Transactionally bound programs client/server and server/server programs. The message 13 . Batch transactions run in low priority mode. Simply put. All this is made transparent to them —very much like an operating system makes the hardware transparent to ordinary programs. MOM -based Queued transaction can be of either type. They also provide a framework for running server applications. TP Monitors provide the run-time engines for running transactions —they do that on top of ordinary hardware and operating systems. they run in high-priority mode. invocation causes the recipient program to join the transaction Commit No Yes Synchronization Only-once No Yes semantics Server No Yes. restarts transient. Exchanges are entire ex change. load the recipient balanced. Several provided servers can read from the same queue Supervised No. and provided persistent queues and crash recovery TP Monitor standards XA OTS MTS/DTC EJB TP Monitor Benefits Client/Server application development framework Firewalls of protection 14 . monitored and tracked node as part of the transaction Load balancing Using directory services. performs retries. The process that receives management on the message is started. redirects error management is provided. messages to an alternate server process if the first one gets hung. Exchanges are simply between The TP Monitor supervises the Exchanges client and server. No crash recovery or communication links. No Uses the TP Monitor’s load dynamic load balancing is balancing algorithms. four operations and the third operation fails. It is RPC plus additional language constructs and run-time support to bundle several RPC calls into an atomic unit extensions to databases and possibly other resource managers to allow them to participate in a 2-phase commit process In a transaction. First. High availability Load balancing MOM integration Scalability of function Reduced system cost Transactional RPC Transactional RPCs are initiated from within the scope of a transaction. each server responds with either a ready to commit message or an abort message (if failures occurred while processing its operation) Third. Once the client ends a transaction. the manager sends an abort message to each server (which may then have to perform a rollback) and the client is notified that the transaction failed. This means that if a transaction has. the transaction manager begins the two phase commit process. TRPC consists of two components: a preprocessor and a library of functions. if all servers are ready to commit. It produces a set of files that 15 . Each transactional RPC does work on behalf of a transaction. Otherwise. the effect of operations one and two must be rolled back. The TIDL preprocessor. for example. tidl. either all operations succeed and an information system's state is updated or all operations fail and the information system's state is unchanged. preprocesses interface definition files. the manager sends a commit message and the client is notified that the transaction was successful. the manager sends a prepare to commit message to each server participating in the transaction Second. and register callbacks (see Application interface). TRPC also exports interface calls to the application developer. Functions used to initialize the TRPC run time interface. This aspect of TRPC is not discussed in this document.must be compiled and linked appropriately with client and the server programs. It also produces an interface definition file that must be processed by IDL. The TRAN communication interface is described in Transaction Service (TRAN). The functions can be categorized into sets as follows: Functions to support the TRAN communication interface. provide information about communication protocols and endpoints. The library of functions provide the relevant communication support for the Distributed Transaction Service (TRAN). 16 . Lite and TP-Heavy Monitors? 17 . Functions that wrap certain DCE RPC run time functions that manipulate RPC handles TRPC supports the following: Piggybacking data on an RPC Handling exceptions during the course of an RPC Aborting an RPC and the enclosed transaction Invoking functions at specific places in an RPC sequence What is TP. TP-Lite Versus TP-Heavy TP-Lite and TP-Heavy is compared in: 1.TP-Lite is simply the integration of TP Monitor functions in the database engines. In contrast. TP-Lite Versus TP-Heavy: Managing Heterogeneous Resources 18 . They can easily provide all-or nothing protection in situations. 2. TP-Lite Versus TP-Heavy: Scope of the Commit TP-Lite stored procedure is written in a a database vendor procedural language and is stored in the database. TP-Lite Versus TP-Heavy: Scope of the Commit 2. TP-Lite Versus TP-Heavy: Managing Heterogeneous Resources 3. TP-Heavy procedures are written standard procedural languages. It can’t help the cause of modularization or writing reusable functions. A stored procedure is a transactional unit but it can’t participate with other transactional units in a global transaction. TP-Heavy is TP Monitors which supports the Client/Server architecture and allow PC to initiate some very complex multiserver transaction from the desktop. TP-Lite Versus TP-Heavy: Client/Server Invocations 1. TP-Lite Versus TP-Heavy: Process Management 4. more processes are automatically started. executed under ACID protection and may then be cached in memory for future reuse. In contrast. Server classes support priorities and other class of service attributes. Loads are balanced across the server classes. TP-Heavy procedures can easily handle ACID updates on multiple heterogeneous resource managers with in the scope of a single transaction. 3. Server classes run copies of the applications business logic-so they are ready to act on incoming requests from clients.A TP-Lite stored procedure can only commit transaction resources that are on the vendor’s database or resource manager. It cannot synchronize or commit work that is on a foreign database or resource manager-whether local or remote. TP-Lite Versus TP-Heavy: Process Management A TP-Lite stored procedure gets invoked. TP-Heavy processes are pre started and managed as server classes. In contrast. If the load on a server class gets too heavy. 19 . It has firewalls around them that the programs that run within them don’t interfere with each other. 20 . TP-Lite Versus TP-Heavy: Client/Server Invocations The TP-Lite stored procedure invocation is non-standard. It does not support communications alternatives like conversations. It also support peer-to-peer communications. In contrast. The RPC’s are not defined using an IDL and they are not integrated with global directory. TP-Heavy environment is very open to different communication styles. security and authentication ser vices. The RPC can use DCE as its base. Vendors provide their own RPC invocation mechanism. queues or publish-and-subscribe.4. The communication links are not automatically restarted and they are not under transaction protection. None of the above d. A network connecting computers and other devices with different operating systems and/or protocols a. Which TP Monitors that supports the Client/Server architecture and allow PC to initiate some very complex multi server transaction from the desktop a. TP-lite d. TP-heavy c. TP-heavy c. homogeneous network b. Queued transaction 21 . All the above 2. TP Monitors provide an OS-on top of the existing OS’s that connects in real time these 1000 of impatient humans with a pool of shared server’s processes- this is called a. RPC transaction b. Process 4.OBJECTIVE TYPE QUESTIONS 1. heterogeneous network c. Local Area Network 3. they run in high-priority mode? a. TP-lite b. Which transaction involves a human user that requires immediate attention. funneling b. Mobile network d. TP and OS d. None of the above d. Publish-and-Subscribe transaction d. One of the TP Monitor benefit is a. Batch transaction 6. c. Publish-and-Subscribe transaction d. Performance b. All the above Review Questions 22 . RPC transaction b. Reliability c. TP-heavy c. Queued transaction c. Publish-and-Subscribe transaction d. Which transaction runs as high priority messages too? a. Throughput 8. RPC transaction b. High availability d. Batch transaction 7. Batch transaction 5. TP-light 9. The integration of TP Monitor functions in the database engines is called a. TP-heavy c. Which TP monitors supports the Client/Server architecture and allow PC to initiate some very complex multi server transaction from the desktop? a. TP-lite b. Queued transaction c. TP-lite b. Which transactions run in low priority mode? a. Explain with one example. 2. Explain with example any 4 transaction types.Two Mark Questions 1. 2. Discuss about the applications of Heterogeneous network. How to manage homogeneous network? 23 . 9. What are benefits of TP Monitor? 8. 2. Define ACID property. What is meant by process management? 6. Compare TP-lite and TP-heavy. What are the TP Monitor client/server interaction types? 10. 1. Explain how the transactions in distributed systems. Differentiate TP. Explain in detail TP-monitor. 5. 2. 2. Compare Homogeneous network and heterogeneous network. What are the invocations of client server models? 7. How TP-lite is differentiated from TP-heavy in process management? Big Questions 1. ASSIGNMENT QUESTIONS 1. Compare homogeneous network and heterogeneous network. What do you meant by heterogeneous network? 4. 3. Write short notes on TP monitor. Name any 4 TP Monitor standards.lite and TP-heavy monitor. 1.