Transparent Application Continuity at Scale: Building a Resilient Connection Mesh
Measuring database high availability at the database process level is a vanity metric; if an infrastructure node failover recovers in seconds while client connection pools hang for fifteen minutes on dead TCP sockets, the platform has experienced a production outage.
TL;DR
- Problem: Abrupt database host crashes leave established client TCP sockets open until OS retransmission timers expire (
tcp_retries2), starving application thread pools while legacy TAF aborts in-flight DML withORA-25408.- Answer: Combine Fast Application Notification (FAN) over ONS with Oracle Universal Connection Pool (UCP), the JDBC Replay Driver (
OracleDataSourceImpl), and Transparent Application Continuity (TAC) backed by Transaction Guard (LTXID), addingCMAN-TDMwhen thousands of pods must reconnect without a logon storm.- Watch out: Blocked ONS port
6200disables FAN silently, large batch transactions can exhaust client replay buffers, and external side effects (UTL_HTTP) inside a database transaction will execute twice on replay.
Situation
Microservice platforms running on Kubernetes commonly maintain hundreds or thousands of application pods holding persistent JDBC connection pools against a multi-node Oracle Real Application Clusters (RAC) or Active Data Guard deployment. Under steady-state traffic, those pools keep established TCP connections open to specific RAC instances to avoid per-request TLS and TNS authentication overhead.
When a database host suffers an ungraceful failure—such as a kernel panic, power supply cutoff, or abrupt hypervisor termination—it sends no TCP FIN or RST packet to connected clients. Inside the cluster, Oracle Clusterware’s Cluster Synchronization Services (CSS) detects missing network and voting-disk heartbeats (governed by misscount, defaulting to 30 seconds on Linux RAC), evicts the failed node, and relocates its Virtual IP (VIP) to a surviving instance. The relocated VIP accepts new TCP SYN packets and immediately rejects stale connection attempts via RST for new sockets. From the DBA’s perspective in GV$INSTANCE, the cluster has recovered. Yet application API tiers continue timing out.
The Problem
The outage persists because database cluster recovery and client OS TCP failure detection operate on completely different clocks.
Three failure mechanisms turn a brief node eviction into a prolonged application outage:
- OS TCP Retransmission Backoff: On Linux,
net.ipv4.tcp_retries2defaults to15. When an application thread writes a SQL call onto an already-established socket whose remote host has vanished, the kernel retransmits unacknowledged segments with exponential backoff starting from the measured round-trip timeout (around0.2seconds) and doubling on each retry until capped atTCP_RTO_MAX(120seconds). Across 15 retries, the cumulative wait reaches roughly924seconds (~15.4 minutes) before the kernel returnsETIMEDOUT. Every worker thread executing a query against the dead node blocks for the full duration. Once worker threads saturate, upstream API gateways exhaust their queues and return HTTP 504 errors. - Legacy TAF Aborts In-Flight DML (
ORA-25408): Traditional Transparent Application Failover (-failovertype SELECT) only re-establishes sessions and resumes read-onlySELECTcursors. If a session has an uncommittedINSERT,UPDATE, orDELETEactive when the instance dies, TAF cannot verify whether the commit succeeded or safely replay the mutation; it aborts the call withORA-25408: can not safely replay call. Unless every application service implements idempotent retry logic around every transaction boundary, writes fail visibly. - Post-Failover Logon Storms: When dead sockets finally time out—or when a connection pool detects failures simultaneously across hundreds of pods—every pod attempts to rebuild its
min-pool-sizeconnections at once against the surviving RAC listeners. A sudden burst of1,000pods each opening10connections generates10,000simultaneous TNS listener handshakes, password verifications, and server process spawns (fork/exec), saturating listener and OS CPU on the surviving nodes.
How do platform architects eliminate multi-minute TCP socket hangs, replay in-flight DML with exactly-once safety, and prevent post-failover logon storms without rewriting application business logic?
Options Considered
When post-mortems trace an outage to hanging JDBC sockets or ORA-25408 errors, engineering teams typically evaluate four approaches.
| Option | Mechanism | What It Solves | Where It Breaks | Decision |
|---|---|---|---|---|
| OS TCP / Socket Timeout Tuning | Lower tcp_retries2 and oracle.jdbc.ReadTimeout | Bounds how long a socket blocks on a dead host | Aggressive timeouts cause false disconnects on slow SQL; still drops active DML | Rejected as primary failover mechanism |
Legacy TAF (SELECT) | Client driver re-establishes connection and restarts SELECT cursors | Masks outages for read-only reporting queries | Throws ORA-25408 on any in-flight DML; no Transaction Guard | Rejected for transactional OLTP services |
| Fast Connection Failover (FCF Only) | UCP subscribes to ONS FAN events and purges dead sockets immediately | Eliminates the 15-minute TCP hang in milliseconds | Uncommitted DML still raises an exception to the application | Partial; necessary foundation, insufficient alone |
| FAN + UCP + TAC | FCF plus JDBC Replay Driver (OracleDataSourceImpl) and Transaction Guard (LTXID) | Purges dead sockets and replays uncommitted DML transparently | Requires UCP/Replay Driver, ONS port 6200, and KEEP grants | Chosen for transactional services |
Lowering tcp_retries2 or setting a 2-second ReadTimeout is a blunt instrument: any legitimate query taking 3 seconds gets killed mid-flight, and dead connections still lose their uncommitted transactions. Fast Connection Failover (FCF) solves the socket hang cleanly via out-of-band FAN signaling, but without TAC, applications still receive SQLRecoverableException for any call that was in flight at the moment of the crash. Pairing FCF with TAC and Transaction Guard solves both halves of the problem.
The Intelligent Connection Mesh Architecture
The recommended architecture bridges Clusterware and the application connection pool through out-of-band signaling, client-side request recording, server-side commit verification, and optional proxy multiplexing.
Four components form the mesh:
- Out-of-Band Fast Application Notification (FAN via ONS): Oracle Notification Service (
ONS) runs on every RAC node and publishesNODE_DOWN,SERVICE_MEMBER_DOWN, and load-balancing advisory events over an independent TCP channel (default port6200). Withons.jaron the classpath, UCP automatically learns ONS endpoints from the SCAN/database handshake, subscribes out-of-band, and immediately aborts idle and active sockets pointing to the evicted node, bypassing OS TCP retransmission timers. - Client Replay Buffer (
OracleDataSourceImpl) and Automatic State Tracking: The Oracle JDBC Replay Driver records SQL calls, bind variables, and session state transitions inside an in-memory cyclic buffer from the start of each database request until the request completes or commits. Unlike traditional Application Continuity (-failovertype TRANSACTION), which relies on explicitbeginRequest/endRequestboundaries or UCP pool borrows plus manual session-state callbacks, Transparent Application Continuity (-failovertype AUTOwith-failover_restore AUTOand-session_state AUTO) automatically tracks non-transactional session state changes on the server and re-establishes them on the surviving node without application code changes. If an application mutates an untracked state mid-request, TAC safely disables replay for that request rather than risking silent state corruption. - Transaction Guard (
LTXID) for Exactly-Once Safety: Replaying an uncommitted transaction is safe only if the database guarantees it did not already commit before the crash. With-commit_outcome TRUE, Oracle assigns every transaction a Logical Transaction ID (LTXID). During failover, the Replay Driver queries Transaction Guard on the surviving node: if the transaction is uncommitted, TAC replays the buffered calls; if it already committed, TAC halts replay withORA-41409: cannot replay committed transaction; failover cannot continue, preventing duplicate execution. - Mutable Value Preservation and
CMAN-TDM: Functions such asSYSDATE,SYSTIMESTAMP,SYS_GUID(), andsequence.NEXTVALwould normally return different values on replay. GrantingKEEP DATE TIME,KEEP SYSGUID, andKEEP SEQUENCEinstructs Oracle to preserve and re-inject the original values during replay. For large Kubernetes fleets, placing Oracle Connection Manager in Traffic Director Mode (CMAN-TDM) in front of RAC multiplexes thousands of pod connections onto persistent server processes, absorbing reconnect storms.
1. Database Service Configuration (srvctl)
Create a custom service (never use the default database or PDB service for TAC) with -failovertype AUTO, -failover_restore AUTO, -session_state AUTO, and -commit_outcome TRUE:
srvctl add service -db PRODDB \
-service svc_payments_tac \
-preferred PRODDB1,PRODDB2 \
-available PRODDB3,PRODDB4 \
-failovertype AUTO \
-failover_restore AUTO \
-commit_outcome TRUE \
-drain_timeout 300 \
-replay_init_time 600 \
-failoverretry 30 \
-failoverdelay 1 \
-notification TRUE
srvctl start service -db PRODDB -service svc_payments_tac
2. Mutable Value Privileges
Grant KEEP privileges to the application user so timestamps, GUIDs, and sequence numbers remain identical if a transaction replays on a surviving node:
GRANT KEEP DATE TIME TO payments_app;
GRANT KEEP SYSGUID TO payments_app;
GRANT KEEP SEQUENCE ON payments.order_id_seq TO payments_app;
GRANT KEEP SEQUENCE ON payments.transaction_id_seq TO payments_app;
SELECT name, failover_type, failover_restore, commit_outcome, replay_init_time
FROM dba_services
WHERE name = 'svc_payments_tac';
3. Application Pool Configuration (Spring Boot / UCP)
Configure Spring Boot to use PoolDataSourceImpl with oracle.jdbc.replay.OracleDataSourceImpl as the connection factory and fast-connection-failover-enabled: true (ensure com.oracle.database.ha:ons is on the classpath):
spring:
datasource:
type: oracle.ucp.jdbc.PoolDataSourceImpl
oracleucp:
connection-factory-class-name: oracle.jdbc.replay.OracleDataSourceImpl
url: "jdbc:oracle:thin:@(DESCRIPTION=(CONNECT_TIMEOUT=3)(RETRY_COUNT=30)(RETRY_DELAY=1)(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=TCP)(HOST=rac-scan.corp.internal)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=svc_payments_tac)))"
user: "payments_app"
password: "${DB_PASSWORD}"
initial-pool-size: 20
min-pool-size: 20
max-pool-size: 50
fast-connection-failover-enabled: true
validate-connection-on-borrow: false
connection-wait-timeout: 10
max-connection-reuse-time: 3600
4. Workload Readiness Check (ACCHK)
Before enabling TAC in production, capture representative test traffic using Oracle’s Application Continuity Protection Check (ACCHK) packages to identify non-replayable calls:
-- ACCHK needs 19.11+ and its views created once per PDB (DBMS_APP_CONT_ADMIN.ACCHK_VIEWS).
-- Clear old data first (PDB level), then enable collection for new sessions.
EXECUTE DBMS_APP_CONT_ADMIN.ACCHK_PURGE; -- check the PL/SQL Packages reference for your release's exact signature
EXECUTE DBMS_APP_CONT_ADMIN.ACCHK_SET(TRUE);
-- Run application integration/regression suite against svc_payments_tac...
-- Generate full coverage and diagnostic report
SET SERVEROUTPUT ON FORMAT WRAPPED LINESIZE 160
EXECUTE DBMS_APP_CONT_REPORT.ACCHK_REPORT(DBMS_APP_CONT_REPORT.FULL);
-- Disable collection when finished
EXECUTE DBMS_APP_CONT_ADMIN.ACCHK_SET(FALSE);
How It Rolls Out
Deploy TAC in four gated phases so network reachability, mutable grants, and non-replayable side effects are caught before production cutover.
- Phase 1 — ACCHK Workload Audit: Enable
DBMS_APP_CONT_ADMIN.ACCHK_SET(TRUE)in staging, run the application’s regression suite, and inspectDBMS_APP_CONT_REPORT.ACCHK_REPORT(DBMS_APP_CONT_REPORT.FULL).- Validation gate: Identify and isolate any non-replayable operations (such as
UTL_HTTPexternal calls or unsupported session state mutations) into separate services or outbox patterns. - Rollback: Disable collection with
ACCHK_SET(FALSE)andACCHK_PURGE.
- Validation gate: Identify and isolate any non-replayable operations (such as
- Phase 2 — TAC Service Provisioning: Create
svc_payments_tacviasrvctlwith-failovertype AUTO,-failover_restore AUTO,-session_state AUTO, and-commit_outcome TRUE.- Validation gate: Verify
dba_servicesandsrvctl config servicereflect the exact TAC attributes and FAN notification is enabled. - Rollback: Stop and remove the new service; existing services remain untouched.
- Validation gate: Verify
- Phase 3 —
KEEPGrants and ONS Network Verification: ApplyKEEP DATE TIME,KEEP SYSGUID, andKEEP SEQUENCEgrants, and verify bidirectional TCP connectivity on ONS port6200from Kubernetes worker subnets to all RAC VIPs.- Validation gate: Confirm ONS client registration succeeds and firewall rules permit port
6200across every availability zone. - Rollback: Revoke
KEEPgrants if security policy requires scoping them to a specific service role.
- Validation gate: Confirm ONS client registration succeeds and firewall rules permit port
- Phase 4 — UCP Replay Cutover and Chaos Validation: Switch the application pool to
OracleDataSourceImplwithfast-connection-failover-enabled: true(andCMAN-TDMfor high pod counts). Run a plannedsrvctl relocate serviceand an unplanned node kill in staging.- Validation gate: Confirm dead sockets abort immediately via FAN, uncommitted OLTP calls replay cleanly on the surviving instance, and no
ORA-25408errors occur. - Rollback: Revert
connection-factory-class-nametooracle.jdbc.pool.OracleDataSource(retaining FCF/FAN socket cleanup without replay).
- Validation gate: Confirm dead sockets abort immediately via FAN, uncommitted OLTP calls replay cleanly on the surviving instance, and no
In Practice
Based on how Oracle Clusterware, ONS, UCP, and Transparent Application Continuity behave under failure:
- FAN separates socket cleanup from TCP timeouts: Because ONS delivers
NODE_DOWNandSERVICE_MEMBER_DOWNevents out-of-band, UCP does not wait fortcp_retries2to expire on half-open sockets. Settingvalidate-connection-on-borrow: falseavoids adding a round-tripSELECT 1 FROM DUALping to every borrow while still purging broken connections on failure events. - Transaction Guard prevents silent double-execution: If a node crashes after a
COMMITreaches the redo log but before theOKpacket returns to the client, replaying theINSERT/UPDATEwould corrupt balances. Transaction Guard’sLTXIDoutcome table lets the Replay Driver check the commit status on the surviving instance and raiseORA-41409instead of re-executing a committed transaction. - Planned maintenance drains before replay is needed: Configuring
-drain_timeout 300on the TAC service letssrvctl relocate serviceand rolling Grid Infrastructure patching emit FAN drain notifications so UCP stops routing new borrows to the draining instance and lets active transactions finish normally. Replay is then reserved only for stragglers or sudden unplanned crashes. - Bounded replay windows protect JVM memory: The client replay buffer holds every call and bind variable since the start of the database request. Short OLTP transactions consume minimal heap, whereas long-running batch jobs that update hundreds of thousands of rows in a single uncommitted transaction can exhaust JVM memory or exceed
-replay_init_time. Batch services should therefore use a separate service with-failovertype NONE.
Where It Breaks
TAC and FAN eliminate TCP hang outages, but they introduce strict boundaries around network ports, replay buffer sizing, and transaction determinism.
| Condition | Breaks how | Detect | Mitigate |
|---|---|---|---|
Blocked ONS port 6200 | Firewall drops ONS traffic between RAC nodes and app pods; UCP falls back to slow OS TCP timeouts. | Test nc -zv <rac-vip> 6200 from pods and check UCP/ONS subscriber logs. | Permit TCP 6200 between app subnets and all RAC VIPs/SCAN; monitor ONS registration. |
| Long batch replay OOM | Bulk DML in a single request fills the client JVM replay buffer or exceeds replay_init_time. | OutOfMemoryError in app pods or ACCHK flagging oversized requests. | Route batch pipelines to a dedicated service with -failovertype NONE; commit in small chunks. |
| External side effects in TX | UTL_HTTP or external RPC inside an uncommitted DB transaction executes twice on replay. | ACCHK_REPORT flags non-replayable external calls; duplicate downstream webhooks. | Move external calls out of the DB transaction (transactional outbox) or enforce idempotency keys. |
Already-committed crash (ORA-41409) | Crash occurs after COMMIT but before client ACK; Transaction Guard halts replay with ORA-41409. | Application logs show ORA-41409: cannot replay committed transaction. | Treat ORA-41409 in the API layer as “commit succeeded—verify state rather than retrying.” |
| Untracked session state drift | Mid-request global package state or unlogged session changes prevent safe replay. | ACCHK_REPORT shows replay disabled mid-session due to state mutation. | Set -failover_restore AUTO and -session_state AUTO; keep application sessions stateless. |
| Pod logon storm on failover | Thousands of pods drop and recreate connections simultaneously, saturating TNS listeners. | Listener CPU spike and ORA-12541 / TNS-12535 errors on surviving nodes. | Place CMAN-TDM in front of RAC to multiplex pod connections onto persistent server processes. |
| Replay lock contention | Replayed DML must re-acquire row locks on the surviving node while another session holds them. | enq: TX - row lock contention waits during failover windows. | Keep transactions short and use bounded wait clauses (SELECT ... FOR UPDATE WAIT 10). |
Before promoting any TAC service to production, run a synthetic kill -9 on one RAC instance’s PMON process under sustained OLTP write load while tailing UCP ONS debug logs. Confirm that dead connections drain immediately on FAN event arrival and that V$TRANSACTION shows zero duplicate commits on surviving nodes.
Key Takeaways
- Database eviction speed means nothing if client sockets hang: Without out-of-band FAN notifications, Linux
tcp_retries2 = 15keeps dead pooled connections blocked for ~15 minutes after an ungraceful host crash. - Legacy TAF cannot protect OLTP writes: TAF only replays
SELECTcursors and aborts active DML withORA-25408; transactional workloads require TAC (-failovertype AUTO) withOracleDataSourceImpl. - Transaction Guard (
LTXID) makes replay safe: Enabling-commit_outcome TRUEprevents duplicate commits by halting replay withORA-41409whenever the crashed transaction had already committed. - Audit workloads with
ACCHKbefore cutover: RunDBMS_APP_CONT_ADMIN.ACCHK_SET(TRUE)andDBMS_APP_CONT_REPORT.ACCHK_REPORTin staging to catch external side effects (UTL_HTTP), missingKEEPgrants, and oversized batch requests. - Separate batch from OLTP and multiplex large fleets: Keep bulk batch jobs on
-failovertype NONEto avoid replay buffer OOM, and useCMAN-TDMwhen thousands of pods could trigger a post-failover logon storm.
What to Do Next
- Problem: Passive OS TCP keepalive/retransmission timers leave application connection pools blocked for minutes after an abrupt RAC node crash, while legacy TAF aborts active DML with
ORA-25408. - Solution: Enable Fast Application Notification (FAN) over ONS port
6200, configure a TAC service (-failovertype AUTO -failover_restore AUTO -session_state AUTO -commit_outcome TRUE), grantKEEPprivileges, and switch UCP tooracle.jdbc.replay.OracleDataSourceImpl. - Proof:
DBMS_APP_CONT_REPORT.ACCHK_REPORTconfirms high replay coverage in staging, and a chaos test killing a RAC node shows UCP purging dead sockets immediately while uncommitted OLTP transactions complete on the surviving node. - Action: Run
ACCHK_SET(TRUE)against your staging workload this week, verify port6200reachability from your Kubernetes worker subnets to your RAC VIPs, and migrate your primary OLTP service to UCP with FCF and TAC.
Interactive tools for this topic