+

Search Tips   |   Advanced Search

Storing transaction logs in a relational database

We can, choose to store the Liberty profile transaction logs in a relational database rather than as operating system files. In the WebSphere Application Server full profile, this feature provides high availability (HA) support without having to use a shared file system. The feature is provided in the Liberty profile for compatibility and for evaluation and testing purposes.

The WebSphere Application Server transaction service writes information to a transaction log for every global transaction that involves two or more resources, or that is distributed across multiple servers. These transactions are started or stopped either by applications or by the container in which they are deployed. The transaction service maintains transaction logs to ensure the integrity of transactions. Information is written to the transaction logs in the prepare phase of a distributed transaction, so that if a Websphere Application Server with active transactions restarts after a failure, the transaction service is able to use the logs to replay any indoubt transactions. This allows the overall system to be brought back to a consistent state.

In previous releases of WAS, the transaction logs were stored as operating system files. In WebSphere Application Server v8.5.5 and later, this remains the default configuration but we can choose to store the transaction logs in a relational database management system (RDBMS). This configuration option is aimed at customers working in an HA environment. In previous releases of WAS, HA transaction support required the use of a shared file system to host the transaction logs, such as an NFSv4-mounted network attached storage (NAS) or a storage area network (SAN). This new feature allows customers, particularly those with an investment in HA database technology, to use their HA database as a shared repository for the transaction logs, as an alternative to using a shared file system.

By default, Liberty profile transaction logs are stored in operating system files. However, for compatibility with the WebSphere Application Server full profile, and for evaluation and testing purposes, we can configure the transaction logs to be stored in an RDBMS. We can use any database type that is supported by the Liberty profile.

To configure the Liberty profile transaction logs to be stored in an RDBMS:

  1. Configure a dedicated, non-transactional data source in the Liberty profile server.xml file.

    The following example extract from server.xml shows how to configure the Liberty profile to store its transaction logs in a DB2 database:

    <transaction> 
      <dataSource jndiName="jdbc/tranlogDataSource" transactional="false">
        <jdbcDriver libraryRef="DB2JCC4LIB"/>
        <properties.db2.jcc currentSchema="CBIVP"
          databaseName="SAMPLE" driverType="4"
          portNumber="50000" serverName="localhost" 
          user="db2admin" password="{xor}Oz1tPjsyNjE=" />
      </dataSource> 
    </transaction> 
    
    <library id="DB2JCC4LIB">
      <fileset dir="C:/SQLLIB/java" includes="db2jcc4.jar db2jcc_license_cu.jar"/>
    </library>

  2. (optional) Create the database tables.

    The Liberty profile attempts to create the necessary database tables when the server first starts. When this is not possible, due to insufficient permission for example, the server fails to start. Under these circumstances, we must create the two required database tables manually.

    The following DDL structures show how to create the tables on DB2:

    CREATE TABLE WAS_TRAN_LOG(
      SERVER_NAME VARCHAR(128),   SERVICE_ID SMALLINT,   RU_ID BIGINT,   RUSECTION_ID BIGINT,   RUSECTION_DATA_INDEX SMALLINT,   DATA LONG VARCHAR FOR BIT DATA) 
    CREATE TABLE WAS_PARTNER_LOG(
      SERVER_NAME VARCHAR(128),   SERVICE_ID SMALLINT,   RU_ID BIGINT,   RUSECTION_ID BIGINT,   RUSECTION_DATA_INDEX SMALLINT,   DATA LONG VARCHAR FOR BIT DATA) 

    The following DDL structures shows how to create the database table on Oracle:

    CREATE TABLE WAS_TRAN_LOG(
      SERVER_NAME VARCHAR(128),   SERVICE_ID SMALLINT,   RU_ID NUMBER(19),   RUSECTION_ID NUMBER(19),   RUSECTION_DATA_INDEX SMALLINT,   DATA BLOB)
    CREATE TABLE WAS_PARTNER_LOG(
      SERVER_NAME VARCHAR(128),   SERVICE_ID SMALLINT,   RU_ID NUMBER(19),   RUSECTION_ID NUMBER(19),   RUSECTION_DATA_INDEX SMALLINT,   DATA BLOB)


Parent topic: Administer the transaction service