This is an excerpt from the bestselling book
Oracle Grid & Real Application Clusters. To get immediate
access to the code depot of working RAC scripts, buy it
directly from the publisher and save more than 30%.
Since the RAC system is a
multi-instance single database, whenever one of the instances has
failed, all the client connections to the failed instance receive
error. They can, however, reconnect to the surviving instance on a
different node. Applications can also use a callback function
through an OCI call to notify clients or users of the failover or
control and mask the failover behavior.
TAF enables the application to
automatically reconnect to the database if the database instance to
which the connection is made goes down. After the reconfiguration of
the failed instance is completed, and when the database is
available, the user session is re-authenticated and the open cursors
are either re-executed (failover_mode=SESSION) or can continue
fetching (failover_mode=SELECT). When TAF is utilized, a new
connection to the database is automatically obtained by Oracle. This
allows users to continue working as if the original connection had
TAF functionality is achieved
through the use of the Oracle provided client side network
libraries, the Oracle call interface (OCI). The client needs to use
the Oracle Net OCI libraries to take advantage of TAF. With OCI
callback functions, OCI API applications can monitor the failure
status of the Oracle Instance.
There are seven possible
failover events in the OCI API that can be captured in the
application code. They are
* FO_BEGIN = 1 is used to
indicate that a lost connection has been detected during and a fail
over is starting.
* FO_END = 2 is used to indicate
that a successful fail over occurred.
* FO_ABORT = 3 is used to
indicate that a fail over was not successful and there is no retry
* FO_REAUTH = 4 is used to
indicate that a users handle has been re-authenticated.
* FO_ERROR = 5 is used to
indicate that a fail over was temporarily unsuccessful. This
gives the application the opportunity to fail gracefully or to retry
fail over. This retry is usually done by issuing a SLEEP() and then
retry by returning the value FO_RETRY
* FO_RETRY = 6 is used to tell
OCI to retry failover
* FO_EVENT_UNKNOWN = 7 is used
to indicate a bad failover event
To implement TAF in Real
Application Clusters, Client Applications need to use the JDBC OCI
instead of PL/SQL packages. While RAC supports both thin JDBC and
JDBC OCI, TAF is only supported with JDBC OCI.
Oracle TechNet can provide a
sample as how to use the TAF using OCI driver. The link is: