Oracle Procedural Gateway for APPC User's Guide
Release 9.0.1.0.1 for UNIX

Part Number A90397-01
Go To Documentation Library
Library
Go To Product List
Product
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to next page

5
Implementing Commit-Confirm

Commit-confirm allows the updating of local Oracle resources to occur in the same Oracle transaction as the updating of non-Oracle resources accessed through the Oracle Procedural Gateway for APPC. This chapter assumes that you are familiar with the basic concepts of two-phase commit as discussed in Oracle 9i Server Concepts. This chapter includes the following sections:

Overview of Commit-Confirm

Commit-confirm is a special implementation of two-phase commit that allows a database or gateway that does not support full two-phase commit to participate in distributed update transactions with other databases or gateways that do support full two-phase commit. In this implementation, the commit-confirm site is always the first to be committed, after all other sites have been prepared.This allows all sites to be kept in sync, because if the commit-confirm site fails to commit successfully, all other sites can be rolled back.

Within an Oracle distributed transaction, all work associated with that transaction is assigned a common identifier, known as the Oracle Global Transaction ID. This identifier is guaranteed to be unique, so that it can be used to exclusively identify a particular distributed transaction. The key requirement for commit-confirm support is the ability for the commit-confirm site (in this case, the Oracle Procedural Gateway for APPC) to be able to log the Oracle Global Transaction ID as part of its unit of work, so that if a failure occurs, the gateway's recovery processing can determine the status of a particular Oracle Global Transaction ID by the presence or absence of a log entry for that transaction. A new Oracle Global Transaction ID is generated after every commit or rollback operation.

The Oracle Procedural Gateway for APPC implements commit-confirm using LU6.2 synclevel 1. This is similar to the implementation of single-site update, with the added advantage that resources on both the Oracle site and the OLTP being accessed by the gateway can be updated and kept in sync. The main difference is that the commit-confirm implementation requires some additional programming in the OLTP transaction to perform the transaction logging necessary for recovery support.

Supported OLTPs

Since commit-confirm uses LU6.2 synclevel 1, it can be supported by any OLTP that supports APPC, including CICS/ESA and IMS/TM. The Oracle Procedural Gateway for APPC provides sample commit-confirm applications for both CICS/ESA and IMS/TM.

With CICS/ESA, the standard command-level EXEC CICS interface can be used for all APPC communications. In addition, the CPI-C interface can be used if it is preferred. A sample DB2 update transaction written in COBOL using the EXEC CICS interface is provided with the gateway. Any language supported by CICS can be used for writing commit-confirm transactions.

With IMS/TM, the CPI-C interface must be used, making the IMS transaction an "explicit APPC transaction," as referred to in the IBM IMS/ESA manuals. This is necessary because it is the only way that the LU6.2 synclevel 1 control flows are accessible to the IMS transaction. When using "implied APPC" where "GU" from the IOPCB and "ISRT" to the IOPCB are used for receiving and sending data, there is no way for the IMS transaction to access the LU6.2 synclevel 1 control flow, making it impossible to use this method for commit-confirm. A sample DLI database update transaction written in COBOL using the CPI-C APPC interface is provided with the gateway. Any language supported by IMS and CPI-C can be used for writing commit-confirm transactions.

Required Components

The following components are required to support commit-confirm:

Configuring Commit-Confirm

The steps for configuring commit-confirm include:

All of these steps must be performed before attempting to use any applications that use commit-confirm.

Configuring the Oracle Integrating Server

The Oracle integrating server where the gateway server will store its transaction log information should ideally be on the same machine where the gateway runs. The configuration of the server consists of creating the gateway DBA user, creating the commit-confirm log tables and creating the PL/SQL stored procedure used by the gateway server for logging transactions.

The pgaccau.sql script from the $ORACLE_HOME/pg4appc/admin directory creates the gateway DBA user IF. The default user ID is PGADBA with the initial password set to PGADBA. If you want to change the user ID or initial password, you must modify the script.

  1. Use SQL*Plus to connect to the Oracle integrating server as user SYSTEM.

  2. From SQL*Plus, run the pgaccau.sql script from the $ORACLE_HOME/pg4appc/admin directory. This script creates the gateway DBA user ID. If you want to change the password at any time after running this script, you can use the ALTER USER command to change the password. For further information, refer to the Oracle9i Server SQL Reference.

  3. Use SQL*Plus to connect to the Oracle integrating server as user PGADBA.

  4. From SQL*Plus, run the pgaccpnd.sql script from the $ORACLE_HOME/pg4appc/admin directory. This script creates the PGA_CC_PENDING table used by the gateway server for its commit-confirm transaction log.

  5. From SQL*Plus, run the pgacclog.sql script from the $ORACLE_HOME/pg4appc/admin directory. This script creates the PGA_CC_LOG PL/SQL stored procedure used by the gateway server for updating the PGA_CC_PENDING table.

  6. Disconnect from the Oracle integrating server.

Configuring the Gateway Initialization Parameters

The gateway initialization parameters are discussed in Appendix A, "Gateway Initialization Parameters," of the Oracle Procedural Gateway for APPC Installation and Configuration Guide for your platform. The parameters necessary for commit-confirm support in the gateway are:

These parameters should be added to your initsid.ora file, where sid is the gateway SID for your commit-confirm gateway.


Warning:

Because the logging and recovery user IDs and passwords are specified in the initsid.ora file, Oracle Corporation recommends that the file permissions be set to remove read permissions for non-DBA users. 


PGA_CAPABILITY must be set to COMMIT_CONFIRM to enable commit-confirm.

PGA_LOG_DB specifies a Oracle Net service name that is used by the gateway server to connect to the Oracle integrating server where the PGA_CC_PENDING table and the PGA_CC_LOG PL/SQL procedure are stored. The service name must be defined in a tnsnames.ora file that is accessible to the gateway server. The gateway server accesses the tnsnames.ora file through the TNS_ADMIN environment variable setting. TNS_ADMIN must specify the full path name of the directory in which the tnsnames.ora file is stored.

PGA_LOG_USER specifies the Oracle user ID that will be used by the gateway when connecting to the Oracle integrating server identified by the PGA_LOG_DB parameter. This user ID is the PGADBA user ID created by the pgaccau.sql script. The user ID specified must be the same user ID under which the pgaccpnd.sql and pgacclog.sql scripts were run.

PGA_LOG_PASS specifies the Oracle password that is used by the gateway when connecting to the Oracle integrating server identified by the PGA_LOG_DB parameter. This is the password for the Oracle user ID specified by PGA_LOG_USER.

PGA_RECOVERY_USER specifies the user ID that is used by the gateway when allocating an LU6.2 conversation with the transaction specified by the PGA_RECOVERY_TPNAME parameter. This parameter is necessary only if the PGA_SECURITY_TYPE parameter has been set to "PROGRAM".

PGA_RECOVERY_PASS specifies the password that is used by the gateway when allocating an LU6.2 conversation with the transaction specified by the PGA_RECOVERY_TPNAME parameter. This parameter is necessary only if the PGA_SECURITY_TYPE parameter has been set to "PROGRAM".

PGA_RECOVERY_TPNAME specifies the TP name of the transaction installed in the OLTP for performing operations against the commit-confirm transaction log database on the OLTP side. The default value is RECO, which is the name used by the installation procedure for the sample transaction shipped with the gateway. Note that when the OLTP is CICS/ESA, the TP name is limited to four characters, and when the OLTP is IMS/TM, the TP name is limited to eight characters. Other OLTPs may have other limits on the length of the TP name.

Configuring the OLTP

Configuration of the OLTP includes the following:

Detailed instructions for configuring CICS/ESA and IMS/TM are provided in the $ORACLE_HOME/pg4appc/demo/CICS/README.doc and $ORACLE_HOME/pg4appc/demo/IMS/README.doc files, respectively.

Application Design Requirements

When designing commit-confirm applications for use with the Oracle Procedural Gateway for APPC, there are some requirements you must meet to provide the ability for the gateway to determine the state of a transaction in the event of a failure. If these requirements are not met, attempting to use an application with a commit-confirm gateway will produce unpredictable results.

The first thing that must be done by an OLTP transaction invoked by a commit-confirm gateway is to receive the Oracle Global Transaction ID from the gateway and log it into the OLTP commit-confirm transaction log database. This must be done before the normal data flow between the OLTP transaction and the Oracle application begins. The gateway always sends the Oracle Global Transaction ID as the very first data item.

If the OLTP transaction is a one-shot transaction, this is the only change needed. If the transaction is a persistent transaction that performs more than one unit of work (issues more than one commit or rollback), then a new Oracle Global Transaction ID must be received and logged after every commit or rollback.

The Oracle Global Transaction ID is sent by the gateway in a variable-length record with a maximum length of 202 bytes. The first 32 bytes contain a special binary string used to verify that the data came from the gateway and not from some other application. The next 1 byte is a reserved field. The Oracle Global Transaction ID is next, with a maximum length of 169 bytes. You must log the reserved field and the Oracle Global Transaction ID, as well as a date/time stamp and any other information you wish to log. Note that the Oracle Global Transaction ID must be the key field for the log database so that the forget/recovery transaction can use the Oracle Global Transaction ID to directly access a log entry.


Note:

If your OLTP is IMS/TM, you must add a PCB for the commit-confirm transaction log database to the PSB for each transaction that you will use with a commit-confirm gateway. This PCB must be the first PCB in the PSB. 


Commit-Confirm Architecture

The architecture of the commit-confirm implementation in the Oracle Procedural Gateway for APPC consists of three main components:

This section describes the role each component plays in the operation of commit-confirm and how these components interact.

Components

The Oracle integrating server is the controlling component in the commit-confirm architecture. It tells the gateway server when to commit a transaction and when to rollback a transaction. It does the same with all other servers participating in a distributed transaction. When a failure has occurred, it is the integrating server which drives the recovery process in each participating server, including the gateway server.

The gateway server performs the task of converting instructions from the Oracle integrating server into LU6.2 operations and then logs the transaction into the Oracle logging server. The gateway server stores the log information in a table called PGA_CC_PENDING on the logging server. If a failure occurs during transaction processing, the gateway server determines which error should be returned to the integrating server.

The Oracle logging server is an Oracle server available to the gateway server for storing and accessing its commit-confirm log information. The logging server need not be the same Oracle server as the integrating server, but can be. Because the logging server is an integral component of gateway commit-confirm operations, the best place for it to reside is on the same machine as the gateway server. This allows the communication between the gateway server and the logging server to use interprocess communications, providing a high-speed, low overhead, local connection between the components.

Interactions

There is a specific set of interactions that occur between the components. They are:

Commit-Confirm Flow

The flow of control for a successful commit between an Oracle application and an OLTP transaction is shown in Figure 5-1, "Commit-Confirm Flow with Synclevel 1". This figure assumes that both Oracle and OLTP resources have been updated. The steps below outline the commit-confirm logic flow.

Commit-Confirm Logic Flow, Step by Step

  1. The application issues a COMMIT to the Oracle integrating server.

  2. The Oracle integrating server sends PREPARE to each participant in the distributed transaction other than the gateway.

  3. Each participant prepares its database updates and responds PREPARE OK to the Oracle integrating server.

  4. The Oracle integrating server sends COMMIT to the gateway. The gateway receives the COMMIT from the Oracle integrating server and inserts a new pending transaction row into the PGA_CC_PENDING table.

  5. The gateway sends an APPC CONFIRM to the OLTP application. The OLTP application receives the CONFIRM request in the form of a status from the last APPC RECEIVE.

  6. The OLTP application issues a COMMIT using an appropriate OLTP function. The OLTP commits all database updates made by the application since the last COMMIT, including the commit-confirm transaction log update.

  7. Once the database updates have been committed, the OLTP returns control to the application with a return code indicating the status of the COMMIT.

  8. The OLTP application sends an APPC CONFIRMED to the gateway.

  9. The gateway receives the CONFIRMED and returns COMMIT OK to the Oracle integrating server.

  10. The Oracle integrating server sends COMMIT to each participant in the distributed transaction other than the gateway.

  11. Each participant commits its database updates and responds COMMIT OK to the Oracle integrating server.

  12. The Oracle integrating server sends a FORGET to the gateway.

  13. The gateway receives the FORGET and starts a new APPC conversation with the FORGET/RECOVERY transaction at the OLTP, sends it a FORGET request and an APPC CONFIRM. The FORGET/RECOVERY transaction receives the FORGET request and deletes the entry from the commit-confirm transaction log for the current Oracle transaction, and commits the delete.

  14. The FORGET/RECOVERY transaction sends an APPC CONFIRMED to the gateway to indicate that the FORGET was processed, and then terminates. The gateway receives the CONFIRMED and deletes the pending transaction row from the PGA_CC_PENDING table.

  15. The gateway returns FORGET OK to the Oracle integrating server.

  16. The Oracle integrating server returns control to the Oracle application.

Figure 5-1 Commit-Confirm Flow with Synclevel 1


Text description of ch5a.gif follows
Text description of the illustration ch5a.gif

Gateway Server Commit-Confirm Transaction Log

The commit-confirm transaction log consists of a single table, PGA_CC_PENDING. This table contains a row for each in-flight Oracle transaction that includes the commit-confirm gateway. The table is maintained by the gateway server and is similar in function to the Oracle server's DBA_2PC_PENDING table. Note that a row is not inserted into this table until a COMMIT is received by the gateway and the row is deleted when a FORGET is received by the gateway. There is no involvement by the gateway during the PREPARE phase.

The PGA_CC_PENDING table contains the following columns:

Sample Applications

Samples are provided with the gateway for CICS/ESA and IMS/TM for implementing commit-confirm support. They are in the following directories, respectively: $ORACLE_HOME/pg4appc/demo/CICS and $ORACLE_HOME/pg4appc/demo/IMS. A README.doc file in each directory provides detailed information about installing and using the samples. JCL files for compiling and linking the sample programs are provided as well. The samples included with the gateway assist you with the following:


Go to previous page Go to next page
Oracle
Copyright © 2001 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Library
Go To Product List
Product
Go To Table Of Contents
Contents
Go To Index
Index