1 / 36

TP Monitors And ORBs

TP Monitors And ORBs. Chapter 5. Application. Transaction . operator . databases (SQL) . distributed name . Processing . interface . disaster recovery . binding . Services . configuration . server invocation . (TRAPS). load control . resource managers . protected user .

kyrie
Download Presentation

TP Monitors And ORBs

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TP Monitors And ORBs Chapter 5

  2. Application Transaction operator databases (SQL) distributed name Processing interface disaster recovery binding Services configuration server invocation (TRAPS) load control resource managers protected user flow control prog.environ. interface TRANSIDs transaction manager transactional RPC Transaction server class log, context transactional Processing request scheduling durable queue session Operating resource mgr. i/f. transactional file System authentication archive RPC (TPOS) repository process / thread IPC simple Basic file system address space sessions Operating directory scheduling (open/close, System extents IPC write/read) (BOS) blocks local naming naming protection file security authentication wires, fibers, memory processors Hardware switches ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  3. The Resource Manager Interface response rmCall(...) administrative functions and callbacks for installing, starting, and scheduling a resource res. manager's own service interface manager invocation functions To and from rmCall(...) TP-monitor and other system other transaction Resource resource resource management Manager managers managers (used for (depends on application) transaction callbacks callbacks control) ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  4. Some Terminology • TP-Monitor: This term denotes an operating system extension that understands transactions. • Resource Manager: This is a system component that offers useful services to certain user groups and that protects its resources by transactions. An example of a very important resource manager is a database system. • rmCall: This is used as a generic call to any kind of resource manager. The call specifies the name of the resource manager, the operation that should be executed, and the parameters for the operation. If there is a database containing course information, such a call could look like this: rmCall (“CourseDB”, “select Course-No, Ctitle from Courses, Offerings where Term = “Summer 1999” and ….”, ...) • Callback: When a module calls some other module and that module in turn invokes the module that called it, the technical term for that mechanism is: callback. ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  5. Some Interface Definitions typedef struct /* handle for identifying the specific instantiation */ { /* of a resource manager */ NODEID nodeid; /* node where process lives */ PID pid; /* process request is bound to */ TIMESTAMP birthdate; /* time of server creation */ } rmInstance; /* identifies a specific server */ typedef struct /* resource manager parameters */ { Ulong CB_length; /* number of bytes in CB */ char CB_bytes [CB_length]; /* byte string */ } rmParams; Boolean rmCall(RMNAME, /*inv. of RM named RMNAME */ Bindld* BoundTo, /* expl. with bind mechanism */ rmParams * InParams, /* params to the server */ rmParams * OutResults); /* results from server */ ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  6. RM Callbacks for the TM Boolean rm_Prepare(); Boolean rm_Rollback_Savepoint(Savepoint); Boolean rm_Commit(Boolean); Boolean rm_Savepoint(); (void) rm_UNDO(&buffer); (void) rm_Abort(); (void) rm_REDO(&buffer); (void) rm_Checkpoint(); (void) TM_Startup(lsn); ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  7. Control Flow in Transactional RPCs ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  8. RM Calls vs. RM Sessions • Independent invocations: A server of class S can be called arbitrarily often, and the outcome of each call is independent of whether or not the server has been called before. Moreover, each server instance can forget about the transaction by the time it returns the result. Since the server keeps no state about the call, there is nothing in the future fate of the transaction that could influence the server’s commit decision. Upon return, the server declares its consent to the transaction’s commit, should that point ever be reached. ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  9. RM Calls vs. RM Sessions • Invocation sequence: The client wants to issue service requests that explicitly refer to earlier service requests; for example, “Give me the next 10 records.” The requirement for such service requests arises with SQL cursors. First, there is the OPEN CURSOR call, which causes the SELECT statement to be executed and all the context information in the database system to be built up. As was shown, this results in an rmCall to the sql server. After that, the FETCH CURSOR statement can be called arbitrarily often, until the result set is exhausted. If it was an update cursor, then the server cannot vote on commit before the last operation in the sequence has been executed; that is, the server must be called at its rm_Prepare() callback entry, and the outcome of this depends on the result of the previous service call. ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  10. RM Calls vs. RM Sessions • Complex interaction: The server class must remember the results of all invocations by client C until commit, because only then can it be decided whether certain deferred consistency constraints are fulfilled. Think of a mail server. The server creates the mail header during the first interaction, the mail body during the next interaction, and so on. The mail server stores the various parts of a message in a database. All these interactions are independent; the client might as well create the body first, and the header next. However, the mail server maintains a consistency constraint that says that no mail must be accepted without at least a header, a body, and a trailer. Since this constraint cannot be determined until commit, there must be some way of relating all the updates done on behalf of the client when the server is called (back) at rm_Prepare. ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  11. Context Management - I ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  12. Context Management - II ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  13. Types of Context Information • Client-oriented context: The solutions presented so far implicitly assume that this is the type of context to be managed. Typical examples are cursor positions, authenticated userids, etc. • Transaction-oriented context: Consider the following example: Client C invokes server S1, which in turn invokes server S3—all within T. After return from the service call, C invokes S2 (a different server class), which also invokes S3, but needs the context established by the earlier call to S3 from S1. The point here is that the context needed by S3 is not bound to any of the previous client-server interactions, but it is bound to the transaction as such. This leads back to the argument about the similarities between sessions and transactions in terms of context management. Examples of transaction-oriented context are deferred consistency constraints and locks. ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  14. Managing Context • Session management: If context maintenance is handled through communication sessions, then theTP monitor is responsible for binding a server process to one client for the duration of a stateful invocation. • Process management: Even if the TP monitor has no active responsibility for context management, it may use information about the number of existing sessions per server for load balancing. The rationale is that an established session is an indicator for more work in the future. ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  15. More Interfaces typedef struct {rmInstance EndA; /* one end of stateful interaction */ rmInstance EndB; /* other end of stateful interaction */ Uint SeqNo; /* sequence no. to distinguish */ /* between stateful interactions */ /* among the same servers. */ } BindId; /* handle for a stateful interaction */ BindId rmBind(rmInstance); /* passes the id of client to which */ /* a session has to be established. */ /* gets a handle for the interaction */ /* among this server and this client. */ /* returns null if binding fails. */ Boolean rmUnbind(BindId); /* inverse to rmBind. */ ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  16. More Interfaces PID MyProcid(); /* returns ID of process the caller is running in*/ /* this is actually a call to the basic os */ TRID MyTrid(); /* returns the TA ID the caller is executing in */ RMID MYRMID(); /* returns RMID of the RM that has called */ RMID ClientRMID(); /* returns the RMID of the caller’s client */ PCB MyProc(); /* returns a copy of the process control block */ /* descr. the process the caller is running in */ TransCB MyTrans(); /* returns copy of the transaction ctl. block. */ /* describing the TA the caller is working for */ RMCB MyRM(); /* returns copy of the resource mgr. control */ /* block desc. the RM that issued the call */ RMCB ClientRM(); /* like MyRM, but for the caller’s client */ ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  17. Schema of the Transactional Objects ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  18. Name Binding for rmCalls ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  19. The CORBA-Way of Saying It ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  20. OTS: The BIG Picture 3 resource rec. object TA client 2 TA object 3 Sub-TA res. Recoverable server TA server 4 6 5 1 7 TA context Object Transaction Service Object Request Broker (ORB) ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  21. OTS Interfaces 1 A transactional client requests begin or end of transaction. If upon a begin request, a TA already exists, a sub-TA is started. 2 The client invokes operations from a transactional object. Such an object has no persistent state. 3 Requests can also be made at recoverable objects. 4 Registers a resource object with the OTS for commit coordi-nation; may initiate rollback. ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  22. OTS Interfaces 5 A resource understanding sub-TAs implements what is needed for completing a sub-TA, passing the locks to the parent, etc. 6 A resource participates in the 2PC, makes changes to persistent state durable, performs recovery if needed, etc. 7 A transactional object may initiate rollback. ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  23. Transaction Context • OTS maintains a transaction context for each active TA. It is associated with all transactional operations. • The TA context is an implicit parameter for all invocations of TA operations. • The context can also be passed as an explicit parameter. • This is required in environments where both the OTS style and the procedural (X/Open DTP) style of transactions are used in parallel. ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  24. The Transaction´s New Clothes Boolean Debit (Amount amountRequested) { Account theAccount; Branch theBranch; Teller theTeller; History GlobalHistory; Current theCurrentTransaction; theCurrentTransaction.begin(); Amount balance = theAccount.query(); if (balance >= amountRequested) { theAccount.withdraw(amountRequested); theBranch.withdraw(amountRequested); theTeller.withdraw(amountRequested); GlobalHistory.remember(amountRequested); theTeller.dispense(amountRequested); theCurrentTransaction.commit(); return True; else ... ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  25. OTS Interfaces • Current denotes a pseudo object, the methods of which are executed within OTS and ORB. • Invoking begin on an object of class current creates a transaction context that is managed by the ORB until the TA either commits or aborts. • As a result of begin, the newly created context is associated with the client´s “thread of control”, which typically translates into “process”. Multiple threads (in different execution environments) can be associated with the same context at the same time. ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  26. Why Use Queues? • Load control: In case of temporary overload put requests into a queue for the server class rather than flood the system with new processes. • End-user control: Queue can maintain the output of asynchronous transactions for delivery until the user explicitly acknowledgs receipt. • Recoverable data entry: Requests put on server’s queue. Server application processes requests as fast as it can. • Multi-transaction requests (Workflow): Requests are processed by a server which passes results on to another server for further processing. This can go on for many steps. If none of the steps interacts with a user, they can all be executed asynchronously. ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  27. Workflow Management Using Queues output queue of output queue of output queue client A / server 1 / of server 2 / input queue of input queue of input queue of server 1 server 2 server 3 ClientA Server1 Server2 might be identical ClientB Server4 Server3 output queue output queue of server 4 / of server 3 / response queue input queue of of client B server 4 ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  28. Durable Queues for Asynchronous Transactions 1. transaction 2. transaction receive send request request client server send receive response response 3. transaction ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  29. Queued Transaction Processing • Request-reply matching: The system guarantees that for each request there is a reply—even if all the reply says is that the request could not be processed. • ACID request handling: Each request is executed exactly once. Storing the response is part of the ACID transaction. • At-least-once response handling: The client is guaranteed to receive each response at least once. As explained previously, there are situations where it might be necessary to present a response repeatedly to the client. This means the client must prepare itself for properly dealing with duplicate responses. The important thing about the at-least-once guarantee, though, is the fact that no responses will be lost. ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  30. Queuing Interfaces Boolean send( REQUEST DoThis, RQID rqid, QUID ToQueue, QUID RespQueue); receive(QUID RespQueue, RESPONSE KeepThat); RESPONSE reReceive(QUID RespQueue); Registering a client with a queue establishes a recoverable session between the client and the queue resource manager. This is another example of the stateful interaction between a client and a server. The queue resource manager remembers theRQIDs it has processed, and the client knows whether it can send a request to the server queue, or whether it has to wait for a response from its input queue. ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  31. A Sample Queue Manager Boolean send(QAttrPtr); /* RM interface for enqueueing a request */ { /* for simplicity no checking if the requesting */ /* rm is in session with the designated queue*/ /* insert the parameters passed into relation */ exec sql insert into sys_queues values (:(QAttrPtr->quid), :(QAttrPtr->q_type), :(QAttrPtr->from_rmid), :(QAttrPtr->to_rmid), CURRENT,:(QAttrPtr->rqid), :(QAttrPtr->keepthat), :(QAttrPtr->request_response), 0, NULL); / return(sqlcode == 0); }; ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  32. A Sample Queue Manager Boolean receive(QUID from_there, QAttrPtr); { exec sql declare cursor dequ on /* def scan over Q */ select * FROM sys_queues where quid = :from_there and delete_flag = NULL order by rqid ascending for update <some isolation clauses>; while (TRUE) /* try until entry is found */ { exec sql open dequ; exec sql fetch dequ into :(QAttrPtr->QAttr); if ( sqlcode == 0 ) /* found an entry */ { exec sql update where current of cursor dequ set delete_flag = ‘D’; exec sql close dequ; return(TRUE); }; exec sql CLOSE dequ; wait(1); }; }; ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  33. Load Balancing ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  34. Throughput thrashing threshold thrashing mode normal mode Response Time Thrashing ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  35. request Node Node scheduling server 2 1 server by class A class A TP monitor server class B scheduling server by class B database RPC back TP server database to monitor server disk node 1 disk server because server data reside in partition A data data partition partition B A Data Affinity ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

  36. The Authentication Problem ©Jim Gray, Andreas Reuter Transaction Processing - Concepts and Techniques WICS August 2 - 6, 1999

More Related