Transparent Application Failover (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.
This is true regardless of how the connection was lost.
When an Instance shut down unexpectedly or get crash , active sessions of that sessions start throwing exceptions to client.Here TAF[Transparent Application Fail-over] comes into picture.It enables application to transparently reconnect to a secondary instance . It creates a fresh connection that is identical to the connection previously established on original instance . Connection properties remain same as original connection.
In this case, the active ,non committed transactions will be rolled back.
TAF can be implemented by two way.
- Server Side TAF
- Client Side TAF
- Server Side TAF : Service attributes are used server-side to hold the TAF configuration.
Services simplify the deployment of TAF. You can define a TAF policy for a service, and all connections using this service will automatically have TAF enabled. This does not require any client-side changes.
To define a TAF policy for a service, use SRVCTL as in the following example :
$ srvctl add service -d orcl -s prefailover -P BASIC -e SELECT -z 5 -w 120
2. Client Side TAF : We can use tnsnames.ora file to configure TAF.
We can use following tnsnames.ora parameters while using client side TAF
orcl = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = rac1)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = orcl.orcl_one.com) (FAILOVER_MODE = (TYPE = SELECT) (METHOD = PRECONNECT) (BACKUP = rac2) ) ) )
Let us understand FAILOVER_MODE parameters.
- BACKUP : We can specify a net service name to be used to establish the shadow connection.A backup should be defined when using PRECONNECT to pre-establish connections.Specifying a BACKUP is strongly recommended for BASIC methods,otherwise reconnection might first attempt retry to the instance that has just failed and that adds additional delay until the client reconnects.
- TYPE : It specifies the type of fail-over. There are three types of failover functionality are available.
- SESSION : When a connection is lost, a new connection is created automatically
- SELECT :SELECT statements that are in progress during the failure are resumed over the new connection.
It enables a user with open cursors to continue fetching on them after failure.Oracle Net keeps track of any SELECT statements issued in the current transaction, as well as how many rows have been fetched back to the client for each cursor associated with a SELECT statement.
If a instance gets crashed, Oracle Net establishes a connection to a backup instance, re-executes the SELECT statements, and positions the cursor so client can continue fetching rows as if nothing had happened.
Note: No DML operations are transferred. - NONE:No failover functionality is implemented.
3. METHOD : Determines the speed of the failover from the primary to backup mode.
- BASIC : Establishes connection at failover time.
- PRECONNECT : When using PRECONNECT , we can take advantage of shadow session that establishes a second connection to another (backup) instance. This eliminates the reconnection penalty but requires that the backup instance support all connections from all nodes set up this way.
Settings configured server-side supersede their client-side counterparts if both methods are used. Server-side configuration of TAF is the preferred method.
Stay tuned for More articles on Oracle RAC
Thank you for giving your valuable time to read the above information.
If you want to be updated with all our articles send us the Invitation or Follow us:
Telegram Channel : https://t.me/helporacle
Skant Gupta’s LinkedIn: www.linkedin.com/in/skantali/
Joel Perez’s LinkedIn: Joel Perez’s Profile
LinkedIn Group: Oracle Cloud DBAAS
Facebook Page: OracleHelp
nice explanation