Failover for automatic client reroute can be seamless or
non-seamless. If failover for connections to DB2® for Linux, UNIX, and Windows is
not seamless, you need to add code to account for the errors that
are returned when failover occurs.
If failover is non-seamless, and a connection is reestablished
with the server, SQLCODE -4498 (for Java™ clients)
or SQL30108N (for non-Java clients) is returned to the application.
All work that occurred within the current transaction is rolled back.
In the application, you need to:
- Check the reason code that is returned with the error. Determine
whether special register settings on the failing data sharing member
are carried over to the new (failover) data sharing member. Reset
any special register values that are not current.
- Execute all SQL operations that occurred during the previous transaction.
The following conditions must be satisfied for failover for connections
to DB2 for Linux, UNIX, and Windows to
be seamless:
- The application programming language is Java, CLI, or .NET.
- The connection is not in a transaction. That is, the failure occurs
when the first SQL statement in the transaction is executed.
- If transaction-level load balancing
is enabled, the data server allows transport reuse at the end of the
previous transaction.
- All global session data is closed or dropped.
- There are no open, held cursors.
- If the application uses CLI, the application cannot perform actions
that require the driver to maintain a history of previously called
APIs in order to replay the SQL statement. Examples of such actions
are specifying data at execution time, performing compound SQL, or
using array input.
- The application is not a stored procedure.
- Autocommit is not enabled. Seamless failover can occur when autocommit
is enabled. However, the following situation can cause problems: Suppose
that SQL work is successfully executed and committed at the data server,
but the connection or server goes down before acknowledgment of the
commit operation is sent back to the client. When the client re-establishes
the connection, it replays the previously committed SQL statement.
The result is that the SQL statement is executed twice. To avoid this
situation, turn autocommit off when you enable seamless failover.