Configure Application Continuity on Autonomous Database

To configure Application Continuity you must enable application continuity for the database service your application uses and configure the failover type and the drain timeout. In addition, you must set several connection string parameters that enable high availability.

Configure Your Service to Enable Application Continuity

Use DBMS_APP_CONT_ADMIN to enable Application Continuity or Transparent Application Continuity:

  • Application Continuity (AC): Set this failover option using the procedure DBMS_APP_CONT_ADMIN.ENABLE_AC. The ENABLE_AC procedure takes three parameters: SERVICE NAME is the service name to change, FAILOVER_RESTORE, set to LEVEL1 to select Application Continuity(AC), and REPLAY_INITIATION_TIMEOUT, is the replay timeout that specifies how many seconds after a request is submitted to allow that request to replay.

    For example, as the ADMIN user, to enable Application Continuity for the TPURGENT service:

    execute DBMS_APP_CONT_ADMIN.ENABLE_AC(
            'databaseid_tpurgent.adb.oraclecloud.com', 'LEVEL1', 600);
  • Transparent Application Continuity (TAC): Set this failover option using the procedure DBMS_APP_CONT_ADMIN.ENABLE_TAC. The ENABLE_TAC procedure takes three parameters: SERVICE NAME is the service name to change, FAILOVER_RESTORE, set to AUTO to select Transparent Application Continuity (TAC), and REPLAY_INITIATION_TIMEOUT is the replay timeout that specifies how many seconds after a request is submitted to allow that request to replay.

    For example, as the ADMIN user, to enable Transparent Application Continuity for the TP service with the replay timeout set to 20 minutes:

    execute DBMS_APP_CONT_ADMIN.ENABLE_TAC(
            'databaseid_tp.adb.oraclecloud.com', 'AUTO', 1200);
    
  • Disabled: Disable failover using the procedure DBMS_APP_CONT_ADMIN.DISABLE_FAILOVER().

    For example, as the ADMIN user, to disable failover for the TP service:

    execute DBMS_APP_CONT_ADMIN.DISABLE_FAILOVER(
            'databaseid_tp.adb.oraclecloud.com');
    

Find the Service Name Parameter for Application Continuity

Depending on your workload type, use a command similar to the following to SELECT from DBA_SERVICES on your database and identify the service where you want to enable Application Continuity:

  • Data Warehouse

    SELECT name, failover_type FROM DBA_SERVICES;
    NAME                                                    FAILOVER_TYPE
    ------------------------------------------------------- -------------
    nvt21_adb1_low.adb.oraclecloud.com                      
    nvt21_adb1_high.adb.oraclecloud.com                     
    nvt21_adb1_medium.adb.oraclecloud.com                   
  • Transaction Processing or JSON Database

    SELECT name, failover_type FROM DBA_SERVICES;
    NAME                                                    FAILOVER_TYPE
    ------------------------------------------------------- ----------------
    nvt21_adb1_tp.adb.oraclecloud.com                        
    nvt21_adb1_tpurgent.adb.oraclecloud.com                 
    nvt21_adb1_low.adb.oraclecloud.com                       
    nvt21_adb1_high.adb.oraclecloud.com                      
    nvt21_adb1_medium.adb.oraclecloud.com                   

Notice the FAILOVER_TYPE for the high service has the no value and indicates that Application Continuity is disabled.

Verify Application Continuity is Enabled for a Service

Depending on your workload type, check the output of the query on DBA_SERVICES to verify that Application Continuity is enabled.

  • Data Warehouse

    SELECT name, failover_type FROM DBA_SERVICES;
    NAME                                                    FAILOVER_TYPE
    ------------------------------------------------------- --------------
    nvt21_adb1_low.adb.oraclecloud.com                      
    nvt21_adb1_high.adb.oraclecloud.com                     AUTO
    nvt21_adb1_medium.adb.oraclecloud.com                   
  • Transaction Processing or JSON Database

    SELECT name, failover_type FROM DBA_SERVICES;
    NAME                                                    FAILOVER_TYPE
    ------------------------------------------------------- --------------
    nvt21_adb1_tp.adb.oraclecloud.com                       
    nvt21_adb1_tpurgent.adb.oraclecloud.com                 TRANSACTION
    nvt21_adb1_low.adb.oraclecloud.com                       
    nvt21_adb1_high.adb.oraclecloud.com                     AUTO
    nvt21_adb1_medium.adb.oraclecloud.com                   

The FAILOVER_TYPE value for the high service is now AUTO, indicating that Transparent Application Continuity (TAC) is enabled and the FAILOVER_TYPE value for the tpurgent service is now TRANSACTION, indicating that Application Continuity (AC) is enabled.

Use Fast Application Notification (FAN)

When connecting to Autonomous Database, the Oracle database auto-configures FAN. For application deployments with Autonomous Database, Fast Application Notification (FAN) events for unplanned outages are directed to the connection manager (CMAN) and no client application configuration steps required to use FAN.

FAN is automatically handled for you by the client driver and by the Autonomous Database Connection Manager (CMAN):

  • For planned maintenance events, FAN is sent in-band, directly to the drivers. This requires that applications use Oracle Pools or TAC for request boundaries, or use connection tests.
  • The Oracle Database and Oracle client drivers drain on connection tests and at request boundaries.

See Client Configuration for Continuous Availability on Autonomous Database for more information.

Configure Connection String for High Availability

To maintain high availability, Oracle recommends that you set certain connection string parameters when you connect to Oracle Autonomous Database.

Set the CONNECT_TIMEOUT, RETRY_DELAY, RETRY_COUNT, and TRANSPORT_CONNECT_TIMEOUT parameters in the connection string when you connect to Oracle Autonomous Database. The connect strings embedded in the Oracle-supplied tnsnames.ora file are preconfigured with appropriate values for most applications. In some cases, depending on your applications needs, you may need to change the preconfigured values for a connection string.

Use this TNS for all Oracle clients version 12.2 or higher:

alias =
(DESCRIPTION =
(CONNECT_TIMEOUT= 90)(RETRY_COUNT=50)
(RETRY_DELAY=3)(TRANSPORT_CONNECT_TIMEOUT=3)
(ADDRESS_LIST =
  (LOAD_BALANCE=on)
  (ADDRESS = (PROTOCOL = TCP)(HOST=scan-host)(PORT=1521)))
(CONNECT_DATA=(SERVICE_NAME = service-name)))

Use the following for JDBC connections using Oracle driver version 12.1 or earlier:

alias =
(DESCRIPTION =
(CONNECT_TIMEOUT= 15)(RETRY_COUNT=50)
(RETRY_DELAY=3)
(ADDRESS_LIST =  
   (LOAD_BALANCE=on)  
   (ADDRESS = (PROTOCOL = TCP)(HOST=scan-host)(PORT=1521)))
 (CONNECT_DATA=(SERVICE_NAME = service-name)))

Notes for connection strings:

  • For JDBC and ODP clients, the pool connection wait time should be configured to be longer than the CONNECT_TIMEOUT in the connect string.

  • Do not use Easy Connect Naming on the client because such connections do not have high-availability capabilities.

See Download Client Credentials (Wallets) for information on the tnsnames.ora file.

Configure Driver Specific Client Options

Depending on your client and your driver, you need to assure that the client is properly configured to use Application Continuity when you connect to Autonomous Database

Configure JDBC Thin Driver

Shows details to use Application Continuity with Autonomous Database with a client using the JDBC Thin Driver.

If your application uses the JDBC Thin Driver, follow these recommended practices:

  1. Use JDBC Statement Cache for Coverage and Performance.

    For best coverage and performance, use the JDBC driver statement cache in place of an application server statement cache. This allows the driver to know that statements are closed and memory is to be freed at the end of requests.

    To use the JDBC statement cache, use connection property oracle.jdbc.implicitStatementCacheSize (OracleConnection.CONNECTION_PROPERTY_IMPLICIT_STATEMENT_CACHE_SIZE). The statement cache is per connection. The value for the cache size matches your number of open_cursors. For example:

    oracle.jdbc.implicitStatementCacheSize=nnn where nnn is typically between 10 and 100 and is equal to the number of open cursors your application maintains.

  2. Tune the Garbage Collector.

    For many applications the default Garbage Collector tuning is sufficient. For applications that return and keep large amounts of data you can use higher values, such as 2GB or larger. For example:

    java -Xms3072m -Xmx3072m 

    It is recommended to set the memory allocation for the initial Java heap size (ms) and maximum heap size (mx) to the same value. This prevents using system resources on growing and shrinking the memory heap.

  3. When using the Universal Connection Pool (UCP), disable Fast Connection Failover. For example:

    PoolDataSource.setFastConnectionFailoverEnabled(false)

Configure Oracle Call Interface (OCI) Driver

Shows details to use Application Continuity with Autonomous Database with a client using the Oracle Call Interface (OCI) driver.

If the client application uses the Oracle Call Interface (OCI) Driver, follow this recommended practice:

  • Replace OCIStmtPrepare with OCIStmtPrepare2. OCIStmtPrepare() has been deprecated since 12.2. All applications should use OCIStmtPrepare2(). Transparent Application Continuity (TAC) and Application Continuity (AC) allow OCIStmtPrepare but do not replay this statement.

Do not configure ONS servers in oraaccess.xml:

<ons>
   <servers> 
   <!—Do not enter any values --> 
   </servers> 
</ons>

Also, for Autonomous Database Serverless, do not configure the <fan> section:

<fan>  
<!-- only possible values are "trace" or "error" -->  
    <subscription_failure_action>
   </subscription_failure_action>  
</fan>

Configure ODP.NET Unmanaged Provider Driver

Shows details to use Application Continuity with Autonomous Database with a client using the ODP.NET Unmanaged Provider Driver.

The ODP.NET Unmanaged Provider driver automatically uses Application Continuity when Application Continuity is enabled on the database service that your application uses to connect to Autonomous Database.

When connecting an ODP.NET application to your Autonomous Database Serverless, do not configure ONS servers in oraaccess.xml:

<ons>
   <servers> 
   <!—Do not enter any values --> 
   </servers> 
</ons>