190 likes | 329 Views
Distributed Transactions. Integration of transaction processing. OLTP (Online Transaction Processing) : (Distributed) Transaction processing: Trusted data processing, also during system failures and multi-user access Application examples: - Reservation systems (Booking) - Bank transactions
E N D
Integration of transaction processing OLTP (Online Transaction Processing) : (Distributed) Transaction processing: Trusted data processing, also during system failures and multi-user access Application examples: - Reservation systems (Booking) - Bank transactions - Accounting - Generally: data access in write mode Implementation via TP-Systems / TP-Monitors, since 1960 System examples: - JDBC (pure access interface) - CICS (IBM) - IMS (IBM) - Encina (Transarc / IBM) - Tuxedo (BEA Systems)
JDBC (Java Database Connectivity) • Programming interface for access to relational data bases • Corresponds to ODBC (Open Database Connectivity) • Numerous drivers for different data bases (for instance, Oracle, Sybase, DB2, SQL Server etc.) • Realizes however only direct data base access; improved distributed transaction logic in heterogenic systems requires Transaction Services/ Transaction monitors
Database access via JDBC • try • {//open transaction • BankServer.con.setAutoCommit(false); • //UPDATE Account • pstmt = BankServer.con.prepareStatement("UPDATE Account SET Balance=Balance-? WHERE AccountNumber=? "); //Account • pstmt.setDouble(1, Amount); //Amount • pstmt.setInt(2, Account); • int updated = pstmt.executeUpdate(); • pstmt.close(); //Clean-up • //SELECT AccountStatus and READ CreditLimite • pstmt = BankServer.con.prepareStatement("SELECT X.Balance, Y.CreditLimite FROM Account X, Client Y WHERE X.AccountNumber=? AND X.ClientNumber=Y.ClientNumber"); • pstmt.setInt(1, Account); • rs=pstmt.executeQuery(); • BankServer.con.commit(); • } //end of transaction
Distributed transaction: example Account server S1 Booking 1 Client (Cash desk) Trustiness: Booking is realized also in the case of failure of Client, S1, S2 or network failure finally. Atomicity and Consistency: Composed operations are realized completely or not at all Account server S2 Booking 2 (tied booking) Transaction monitor
Transactions and ACID-criteria Transactions protect the ACID-criteria: • ACID • Atomarity • Call completely or without impacts • Consistency • Transformation between consistent states • Isolation • No overlapping of transaction executions • Durability • Survival of system failures
Realization of fault tolerance • Syntactic support of the example: • begin_distributed_transaction • subtract(account1, amount); Server 1 • add(account2, amount); Server 2 • end_distributed_transaction • abort_distributed_transaction // in the error case • Isolation: • special concurrency control mechanisms • Other properties: • 2-Phase-Commit-Protocol with persistent data storage
Two-Phase-Commit (2PC-Protocol) old Version: K save Data: K‘ Participant (for instance, Server 1) (1a) prepare (1b) ready / abort Coordinator (for instance, Client) (2) commit K := K‘ Old Version: L save Data: L‘ (1a) prepare (1b) ready / abort Participant (for instance, Server 2) (2) commit L := L‘
Two-Phase-Commit: Protocol Input from the network / Output to the network start start prepare / abort - / prepare prepare / ready wait ready abort / abortready / abort ready / commit commit / - abort / - aborted commited aborted commited a) Coordinator b) Participant
Transaction monitor: system example Encina Applications and Tools Screen Transaction Resource Managers Processing Managers Services Base Services Operating and Transport system Properties: -TP-Monitor - Integration of different data bases (RDBMS; relational data bases) and transaction monitors (for instance, CICS over LU 6.2 - SNA) - Integration with CORBA and EJB - Standard conformity (XA, X/Open, ISO/OSI, TP)
Example Possible operations: - local transactions - remote object calls - call of other TP-Monitors - nested transactions transaction {... book ("Lufthansa","FRA-JFK"); book ("USAir","JFK-SFA"); output_ticket(); ...} Scenario: Resource Managers Application server Application server Clients Mainframe
Special implementation aspects • -Optimization via serving of several clients via one server process • (multi-threaded) • Replication of the servers and partially automatic, heuristic load balancing, • fault tolerance - Parallel transactions: transaction {... concurrent {... book ("Lufthansa","FRA-JFK"); book ("USAir","JFK-SFA"); output_ticket(); ...} ...} onCommit printf ("OK"); onAbort printf ("Failure");
Migration and Host-Integration Example: Integration with CICS Server (Unix) CPI-C CPI-C SNA CORBA / EJB LU 6.2 Clients Internet SNA CPI-C Mainframe • Encina as CICS region (from point of view of the mainframe) • Access to mainframe data base possible • Basis: • SNA-Gateway; but today also TCP/IP in mainframe • environment available • CPI-C (Common Programming Interface for Communications • from IBM SAA-Systems Application Architecture) • COBOL-interface to transactional Encina-data systems
System administration Central administrator interface: Monitor- Server Configuration data base Administrator - Structuring in the management area - Software distribution: Distributed File System - Parallel system installation on the basis of configuration data base - Transactional Online Backup
System administration - Re-configuration of application servers via starts / stoppages (online) - Monitoring (for instance, number of transactions, blocking transactions; also with selective filtering) - Automatic re-start of servers after failures - Step-by-step-mode Software-Upgrade (two parallel versions possible) - Uniform management user interface
Tuxedo (BEA Systems) • Transaction Monitor, comparable with Encina, XA-conform • Synchronous and asynchronous transactional calls • Reliable Message Queuing • Event Communication • Language support for C, C++, Cobol, Java • Wide availability
Nested transactions • Problem of simple transactions: • backtracking of larger calculations during long operations • lack of parallelism • Nested transactions with parallel partial transactions • Properties: • separate backtracking of partial transactions • selective repeats • abortion of all partial transactions during abortion of the general transaction( Data versions to keep until end) • inheritance of locks in both directions inside the hierarchy • Systems: Encina, Tuxedo
Example of nested transactions Document processing Format Save Print Pre- processor Formatter Copy 1 Copy 2 Preparation Print operation
Summary: Transactions OLTP / TP-Monitors are essential components for commercial applications Trusted, consistent, distributed data management Optional nested transactions, loading balancing, security aspects Integration with mainframe systems (for instance, CICS-Monitor) Important products: Encina (Transarc) Tuxedo (BEA Systems) Improvement in the Internet-area: TIP (Transaction Internet Protocol): flexible Two-Phase-Commit via TCP/IP