solidDB Help : Programming : Using HotStandby with applications : Transparent Connectivity : Failure transparency in Transparent Connectivity : Principles of connection switch handling
  
Principles of connection switch handling
A connection switch refers to a situation where the driver changes the active server connection. Generally, the reason for a connection switch is a failover to the secondary server or a switchover between the servers.
More specifically, a need for a connection switch is detected from one of the following events:
Event from the secondary server about the state change to PRIMARY ALONE (failover) or PRIMARY ACTIVE (switchover). This is the main (and the fastest) mode of performing the connection switch.
Indication of a state change at the primary server.
Link failure on the active connection.
Connection timeout on the active connection.
The driver executes the connection switch in two steps:
1 The need for the connection switch is detected. The driver returns the following connection switch error on a pending or following request:
 
SQLSTATE
Native code
Message text and description
HY000
25216
Connection switch, some session context may be lost.
The driver has discovered the need for the connection switch. The client is expected to execute a transaction rollback call to finalize the connection switch. This error code and message is received after each consecutive network request call until the rollback call is executed
As a result, the client program executes a rollback command (for ODBC: SQLEndTran() with SQL_ROLLBACK, for JDBC: Connection.rollback()).
Note The connection switch error might be returned on a few consecutive ODBC calls. Therefore, a provision must be made to always respond with a rollback to this error, on any ODBC network request. If this happens in the middle of a transaction, the transaction must be re-executed.
2 After receiving the rollback call, the driver searches for the new active connection:
a First, the driver tries the standby connection.
b If the standby connection is not in the correct state, the driver uses the address list in the TC connection and repeats the connect sequence iteratively for a maximum of 10 seconds.
c If all the efforts fail, the driver returns the following error.
 
SQLSTATE
Native code
Message text and description
08S01
14503
Communication link failure
The driver has failed to establish a new active connection. The TF connection is lost and the client has to reconnect (using a Data Source Info) in order to continue.
The effect of the error is that the connection is lost (as seen by the application). Any further requests for that connection result in the same error.
Go up to
Failure transparency in Transparent Connectivity