Oracle TAF

Oracle RAC

 (TAF) is a feature of the Java Database Connectivity (JDBC) Oracle Call Interface (OCI) driver. It enables the application to automatically reconnect to a database, if the database instance to which the connection is made fails. In this case, the active transactions roll back.

(TAF) is a client-side feature that allows for clients to reconnect to surviving databases in the event of a failure of a database instance. Notifications are used by the server to trigger TAF callbacks on the client-side.

TAF is configured using either client-side specified TNS connect string or using server-side service attributes. However, if both methods are used to configure TAF, the server-side service attributes will supersede the client-side settings. The server-side service attributes are the preferred way to set up TAF.

TAF can operate in one of two modes, Session Failover and Select Failover. Session Failover will recreate lost connections and sessions. Select Failover will replay queries that were in progress.

VIEW :     You can query FAILOVER_TYPEFAILOVER_METHOD, and FAILED_OVER columns in the V$SESSION view to verify that TAF is correctly configured.

When there is a failure, callback functions will be initiated on the client-side via OCI callbacks. This will work with standard OCI connections as well as Connection Pool and Session Pool connections. Please see the OCI manual for more details on callbacks, Connection Pools, and Session Pools.

TAF Database Configurations

TAF works with the following database configurations to effectively mask a database failure:
·         Oracle Real Application Clusters

·         Replicated systems

·         Standby databases

·         Single instance Oracle database

Fast Connection Failover (FCF)

Fast Connection Failover offers a driver-independent way for your Java Database Connectivity (JDBC) application to take advantage of the connection failover facilities offered by Oracle Database 10g. The Fast Connection Failover mechanism depends on the implicit connection cache feature. As a result, for Fast Connection Failover to be available, implicit connection caching must be enabled.

TAF is always active and does not have to be set, it does not work with the OCI Connection Pool.
Oracle recommends not to use TAF and Fast Connection Failover in the same application.

TAF Implementation:

Do not set the GLOBAL_DBNAME parameter in the SID_LIST_listener_name section of the listener.ora. A statically configured global database name disables TAF.

Depending on the FAILOVER_MODE parameters, you can implement TAF in a number of ways. Oracle recommends the following methods:

·         Example: TAF with Connect-Time Failover and Client Load Balancing

·         Example: TAF Retrying a Connection

·         Example: TAF Pre-Establishing a Connection

Example: TAF with Connect-Time Failover and Client Load Balancing

Implement TAF with connect-time failover and client load balancing for multiple addresses. In the following example, Oracle Net connects randomly to one of the protocol addresses on sales1-server or sales2-server. If the instance fails after the connection, the TAF application fails over to the other node’s listener, reserving any SELECT statements in progress. (DESCRIPTION=   (LOAD_BALANCE=on)   (FAILOVER=on)   (ADDRESS=        (PROTOCOL=tcp)         (HOST=sales1-server)         (PORT=1521))   (ADDRESS=        (PROTOCOL=tcp)         (HOST=sales2-server)         (PORT=1521))   (CONNECT_DATA=      (      (FAILOVER_MODE=        (TYPE=select)        (METHOD=basic))))

Example: TAF Retrying a Connection

TAF also provides the ability to automatically retry connecting if the first connection attempt fails with the RETRIES and DELAY parameters. In the following example, Oracle Net tries to reconnect to the listener on sales1-server. If the failover connection fails, Oracle Net waits 15 seconds before trying to reconnect again. Oracle Net attempts to reconnect up to 20 times. (DESCRIPTION=   (ADDRESS=        (PROTOCOL=tcp)         (HOST=sales1-server)         (PORT=1521))   (CONNECT_DATA=      (      (FAILOVER_MODE=        (TYPE=select)        (METHOD=basic)        (RETRIES=20)        (DELAY=15))))

Example: TAF Pre-Establishing a Connection

A backup connection can be pre-established. The initial and backup connections must be explicitly specified. In the following example, clients that use net service name to connect to the listener onsales1-server are also preconnected to sales2-server. If sales1-server fails after the connection, Oracle Net fails over to sales2-server, preserving any SELECT statements in progress. Likewise, Oracle Net preconnects to sales1-server for those clients that use to connect to the listener on sales2-server. (DESCRIPTION=   (ADDRESS=        (PROTOCOL=tcp)         (HOST=sales1-server)         (PORT=1521))   (CONNECT_DATA=      (      (INSTANCE_NAME=sales1)      (FAILOVER_MODE=        (        (TYPE=select)        (METHOD=preconnect)))) (DESCRIPTION=   (ADDRESS=        (PROTOCOL=tcp)         (HOST=sales2-server)         (PORT=1521))   (CONNECT_DATA=      (      (INSTANCE_NAME=sales2)      (FAILOVER_MODE=        (        (TYPE=select)        (METHOD=preconnect))))

TAF supports three types of failover types:

1.SESSION failover – If a user’s connection is lost, SESSION failover establishes a new session automatically created for the user on the backup node. This type of failover does not attempt to recover selects. This failover is ideal for OLTP (online transaction processing) systems, where transactions are small.

2. SELECT failover – If the connection is lost, Oracle Net establishes a connection to another node and re-executes the SELECT statements with cursor positioned on the row on which it was positioned prior to the failover. This mode involves overhead on the client side and Oracle NET keeps track of SELECT statements. This approach is best for data warehouse systems, where the transactions are big and complex

3. NONE — This setting is the default and failover functionality is provided. Use this setting to prevent failover.

Ref:  Doc ID 334471.1