DB2 10.5 for Linux, UNIX, and Windows

Operation of automatic client reroute for connections to the DB2 for Linux, UNIX, and Windows server from an application other than a Java™ application

Automatic client reroute (ACR) provides failover support when an IBM® data server client loses connectivity to the primary server for a DB2® for Linux, UNIX, and Windows database. Automatic client reroute enables the client to recover from the failure by attempting to reconnect to the database through an alternate server.

If automatic client reroute is enabled for a connection to a database, the following process typically occurs when a client attempts to execute an SQL statement by using an existing connection and that connection fails.

  1. The client uses the server list that was returned after the last successful connection to identify which server to access and attempts to reconnect to the database.

    In an environment other than a DB2 pureScale® environment, the server list contains two entries: one for the primary server and one for the alternate server.

    In a DB2 pureScale environment, the server list contains an entry for each member of the DB2 pureScale instance. In addition, if you defined an alternate server for the database, the server list contains an entry for that alternate server. An entry for a member of the DB2 pureScale instance includes capacity information. If connection-level workload balancing is enabled at the client, the client uses that information to connect to the server with the highest unused capacity. The entry for an alternate server has no capacity information. A connection to the alternate server is attempted only if connections to all the DB2 pureScale members fail.

  2. If the automatic client reroute process can reconnect the application to the database, the client reconstructs the execution environment for the new connection. The client receives an updated copy of the server list with updated server information. Error SQL30108N is returned to the application to indicate that the failed database connection was recovered and that the transaction was rolled back. The application is then responsible for further recovery, including repeating any work that was rolled back. If the SQL statement that fails is the first SQL statement in the transaction, automatic client reroute with seamless failover is enabled, and the client is CLI or .NET, the driver replays the failed SQL operation as part of automatic client reroute processing. If the connection is successful, no error is reported to the application, and the transaction is not rolled back. The connectivity failure and subsequent recovery are hidden from the application.

    If automatic client reroute is unable to reconnect the application to the database, error SQL30081N is returned to the application. The application is then responsible for recovering from the connection failure (for example, by attempting to connect to the database by itself).

Automatic client reroute is also used when a new connection attempt fails. In this case, however, if reconnection is successful, no error is returned to the application to indicate that the failed database connection was recovered. If reconnection fails, error SQL30081N is returned.

A seamless failover connection can be established under the following conditions:

If the application turned off the automatic closing of cursors at the server side by setting the SQL_ATTR_EARLYCLOSE attribute to OFF, the CLI driver can perform seamless failover only if the application processed the entire result set.

You can configure the FetchBufferSize keyword to ensure that the size of the result set that the CLI driver prefetches is sufficient to include the EOF character in the first query block. See the Related reference section for further details on FetchBufferSize.

Non-seamless ACR environments have one of the following combinations of settings:

In the non-seamless ACR environment, the receive timeout event triggers the ACR connection error (SQL30108N). The receive timeout event occurs when the ReceiveTimeout keyword value is reached

If you set the QueryTimeout keyword in the non-seamless ACR environment, the following behaviors occur:

If the Interrupt keyword is set to the value of 2 and the SQLCancel() API is explicitly called from the application while an SQL statement is being executed, the ACR connection error (SQL30108N, with failure code 4 and error code 2) is returned to the application.

If you set the tcpipConnectTimeout and memberConnectTimeout keywords and the TCPIP connection timeout or the member connection timeout event occurs in the non-seamless ACR environment, the CLI driver reconnects to a new available member. However, the ACR error (SQL30108N) is not returned to the application.