A Data Guard role transition is not complete when the target reports READ WRITE; it is complete when the broker is healthy, the former primary is safely in its new role, role-based services are online only where intended, clients have discarded invalid sessions, and a business transaction succeeds through the production connection path.

TL;DR

  • Problem: Treating READ WRITE as ready, relying on DNS or L4 proxies to move live Oracle sessions, or auto-retrying a timed-out DGMGRL switchover causes split routing and reconnect storms.
  • Answer: Pair PRIMARY-role Clusterware services, both-site connect descriptors, and FAN/ONS with a single non-retried switchover command that enters OUTCOME_UNKNOWN reconciliation on timeout.
  • Watch out: Once the new primary accepts writes, an automatic reversal is not a rollback—it is a brand-new switchover that requires its own preflight and approval.

Data Guard switchover finishes only when role services, FAN, and writes are verified

Production Context: 2022 | Oracle 19c Data Guard Operations | Technical Review: September 2026

Situation

Oracle Data Guard maintains standby databases by transporting and applying redo. A planned switchover reverses the primary and standby roles without data loss when it completes successfully. A failover is a different operation used after an outage and may lose data depending on protection mode and the state of redo transport. Combining both under a generic “regional failover” button hides a critical safety decision.

The broker reduces the database role change to a governed command and coordinates with Oracle Clusterware or Oracle Restart. Applications still need a service topology that follows the role. Oracle’s documented pattern uses services configured for the PRIMARY role on every database that may become primary, connect descriptors that can locate both sites, and FAN events delivered through Oracle Notification Services (ONS) to supported clients and pools.

That client path is frequently the least-tested part of disaster recovery. A team can validate redo apply every day and still discover during a switchover that an old JDBC driver does not consume FAN, a third-party pool retains dead sessions, only one site’s address is in the connect descriptor, or a synthetic probe bypasses the same service used by production.

The Problem

Why “Switch the Database, Then Change DNS” Is Incomplete

DNS can remain part of endpoint discovery, but it does not manage established sessions. An authoritative record change affects only later resolutions, and caching occurs in operating systems, runtimes, resolvers, and connection pools. More importantly, a live Oracle session contains authentication, transaction, package, and session state. Neither DNS nor a generic layer-four proxy can move that state to another database connection.

Four incorrect assumptions create long outages:

  1. READ WRITE means ready. Open mode alone does not prove the expected DB_UNIQUE_NAME, DATABASE_ROLE, broker health, protection state, PDB open state, role-based service placement, listener registration, or application schema readiness.
  2. A proxy can preserve the session. Envoy’s TCP proxy can choose an upstream for a new TCP connection and can close or drain existing connections. An endpoint update does not transplant an established Oracle Net session. Transparent replay requires database and client cooperation, such as Application Continuity and Transaction Guard, and even then only eligible requests are replayed.
  3. A timed-out switchover is safe to retry. Role transition is not an idempotent write. If the workflow loses its response after the broker commits the transition, retrying the same directional command can fail, target the wrong role assumptions, or trigger conflicting operator action. The correct next step is observation and reconciliation.
  4. All reconnects are harmless. When pools simultaneously discard sessions, the new primary can face a connection storm, authentication CPU, session initialization, and cache-warming pressure. FAN speeds removal of unusable connections, but pool sizing, connection pacing, retry jitter, and database capacity still determine recovery behavior.

DNS cutovers, proxy endpoint swaps, and auto-retried commands fail Data Guard switchovers

The engineering question is: How should a switchover controller drain work, execute exactly one role-change intent, recover from an unknown outcome, and prove end-to-end service without inventing atomicity across the broker, Clusterware, clients, and application tiers?

Options Considered

Four orchestration and routing patterns cover the common ways teams automate Data Guard switchovers.

ApproachClient RelocationTimeout SafetySession StateVerdict
DNS CNAME CutoverTTL cache + dead socketsManual recoveryLost on cutoverRejected alone
L4 Proxy / Mesh SwapNew TCP only; drops txnsNo Oracle role checkLost on socket closeIngress layer only
Auto-Retried DGMGRLUses role servicesRaces completed switchoverNeeds FAN/ACRejected — unsafe
Role Services + ReconcilerBoth-site desc + FAN/ONSOUTCOME_UNKNOWN probeAC/TG where supportedSelected

Role-based services with FAN and reconciled orchestration outperform DNS and auto-retry scripts

DNS CNAME cutover only affects new lookups after TTL expiry and leaves existing connection pools pinned to dead sockets. An L4 proxy or service mesh can redirect new TCP connections, but it cannot migrate authenticated Oracle Net session state or in-flight transactions. Auto-retrying a DGMGRL activity in a workflow engine risks racing an already-committed role transition if the first response timed out. Role-based services with FAN/ONS and an OUTCOME_UNKNOWN reconciler cleanly separate client discovery from non-idempotent broker execution.

The Role-Aware Switchover Control Plane

Use Oracle’s role-aware service and client mechanisms as the data plane. The orchestrator coordinates and records state; it does not pretend the steps form one distributed transaction. Once the new primary accepts writes, an automatic reversal is not a rollback—it is another switchover with new risk and must receive a new decision.

Separate the switchover orchestrator from role-based services and independent site probes

1. Make Client Relocation a Database-Service Contract

Configure a write service on each Data Guard member with a PRIMARY role attribute, using srvctl and the database’s actual Clusterware or Oracle Restart topology. The service name must be the name in application connect descriptors; clients should not connect through the default administrative service. When the broker performs a role transition, it works with Clusterware or Restart to start the role-appropriate service and publish FAN events.

A production connection contract should include:

  • addresses capable of reaching listeners at both potential primary sites, with bounded connect and retry behavior;
  • one role-based SERVICE_NAME, created consistently on both databases;
  • ONS discovery for all sites and Fast Connection Failover enabled for supported Oracle drivers or pools;
  • current, compatible client libraries and no mixed JDBC or ONS JAR versions;
  • pool validation, retry, maximum lifetime, and connection-creation limits tested against the expected outage window;
  • Application Continuity or Transparent Application Continuity only where licensed, supported, and proven for the application’s calls and session state.

FAN is a notification channel, not transaction replay. It tells integrated clients that a service or instance is down or up so pools can remove unusable connections and direct new work correctly. Application Continuity can replay eligible requests after a recoverable interruption. Transaction Guard supplies a commit outcome used by replay. Calls with unprotected side effects, unsupported session state, or replay-disabled behavior may still return an error and require application-level idempotency.

Generic proxies can still provide access control, regional ingress, observability, or connection-rate limits. Treat them as another failure domain. An Envoy endpoint update affects connection selection; it does not understand Oracle transactions, multiplex authenticated sessions safely, or guarantee that in-flight statements continue. Oracle Connection Manager has Oracle-specific capabilities, but its exact concentration, filtering, and Traffic Director features must be designed from its product documentation rather than inferred from a generic TCP proxy.

2. Validate Readiness Before Mutating Roles

Create an immutable operation record containing request ID, source and target DB_UNIQUE_NAME, expected current roles, broker configuration identity, protection mode, application service set, approval, and deadline. Acquire a lease that prevents another workflow or operator integration from initiating a role transition for the same configuration.

The preflight should collect and retain:

  1. SHOW CONFIGURATION and SHOW DATABASE VERBOSE for both members, including errors and warnings.
  2. VALIDATE DATABASE VERBOSE for the target. Use the strict checks supported by the installed release where policy requires them, and separately validate network configuration and SPFILE differences.
  3. Primary transport state and target apply state, unresolved transport errors, redo gaps, standby redo-log readiness, and the broker’s own “Ready for Switchover” result.
  4. Clusterware or Restart ownership plus the exact role, drain, replay, notification, and placement attributes of every application service on both databases.
  5. PDB recovery and saved-state assumptions. The post-transition workflow must verify only the PDBs and services expected on this database, not blindly open every PDB.
  6. Client readiness: FAN subscription health, both-site reachability, pool version, application admission control, and synthetic credentials.
  7. Capacity on the target for the reconnect and cache-warming envelope, including processes, sessions, CPU, storage latency, and downstream dependencies.

Do not require an arbitrary zero-second lag as a substitute for broker readiness. A switchover coordinates a no-data-loss role reversal and may wait for apply to catch up. Lag is still an RTO input: the controller should reject or require elevated approval when the observed drain estimate breaches the business deadline.

For RAC services configured with Application Continuity attributes, the broker SWITCHOVER ... WAIT option can wait for service draining; Oracle documents that the option has no effect for a single-instance database. Draining is bounded. After its timeout, remaining work can be interrupted, so the runbook must define what the application observes and which requests are safe to retry.

3. Reconcile an Ambiguous Role-Change Outcome

Run DGMGRL with a secure external password store or another approved credential mechanism; do not place a SYS password in the process list or workflow payload. The command activity must have automatic retries disabled. A workflow framework may retry read-only probes, but the role-change activity itself changes state to ROLE_CHANGE_SUBMITTED before invocation.

The state machine needs an explicit unknown state:

APPROVED -> PRECHECKED -> DRAINING -> ROLE_CHANGE_SUBMITTED
ROLE_CHANGE_SUBMITTED -> OUTCOME_UNKNOWN -> RECONCILING
ROLE_CHANGE_SUBMITTED -> NEW_PRIMARY_OBSERVED -> VERIFYING
RECONCILING -> NEW_PRIMARY_OBSERVED or MANUAL_INTERVENTION
VERIFYING -> ADMITTING -> COMPLETE

After a timeout or controller crash, query both databases independently using connect identifiers that do not depend on the application service. Compare DB_UNIQUE_NAME, DATABASE_ROLE, OPEN_MODE, broker status, and service state. There are only three safe automation conclusions:

  • Intent achieved: exactly the requested target is primary, the former primary is a standby, and the broker recognizes the configuration. Continue forward verification.
  • Intent not started: original roles remain intact and the broker has no transition in progress. A new attempt may be authorized after the cause is known; it is not an invisible activity retry.
  • Ambiguous or unsafe: databases are unreachable, roles conflict with intent, the former primary is not a viable standby, or broker state is inconsistent. Fence further automation and hand off the evidence bundle.

This distinction is why a simplistic Temporal activity with MaximumAttempts: 3 is dangerous. Durable workflow history is useful, but it cannot make a non-idempotent external mutation idempotent. Idempotency comes from a single durable intent, serialized ownership, and reconciliation of observed Oracle state.

How It Rolls Out

Post-transition verification proceeds from the database outward to the client, with explicit halt gates before admitting production traffic:

Switchover state machine reconciles unknown outcomes before verifying and admitting traffic

  1. Confirm one expected primary with READ WRITE, the target DB identity, expected protection mode, and a broker configuration with no unresolved role-transition error.
  2. Confirm the former primary has reached its intended standby state and redo transport and apply have resumed in the reverse direction. Do not close the event with no remaining DR protection.
  3. For required PDBs, validate open mode, restricted state, and service association.
  4. Confirm the primary-role service is running on the new primary, stopped on the standby as designed, registered with the intended listeners, and publishing notifications.
  5. Open a new connection through the production connect descriptor and service. Check database identity and role from the session to catch routing to the wrong site.
  6. Execute a uniquely identified synthetic transaction in a dedicated table, commit it, read it back through a separate connection, and clean it up through the same governed path.
  7. Restore application admission in cohorts. Watch new sessions per second, authentication and logon time, listener errors, pool pending requests, database CPU, service latency, and application error rate. Stop expansion when a reviewed guardrail trips.

The synthetic transaction must be designed as production data: isolated, auditable, idempotent, and excluded from business reporting. A TCP check or SELECT 1 FROM dual proves connectivity but not write service correctness.

In Practice

Oracle’s documented Data Guard behavior provides a testable pattern: the broker performs the role change, Clusterware or Restart starts services according to role, and FAN informs integrated clients. Application Continuity is supported for physical-standby switchovers subject to configuration and licensing requirements. These are public system behaviors; they are not evidence for fabricated claims of zero errors, millisecond recovery, or dozens of simultaneous switchovers.

Qualify each application service with a failure-injection matrix before attaching it to an RTO:

TestEvidence to retainPass condition
Planned switchover with drainBroker transcript, service events, pool statistics, active-request outcomesDrain is bounded; eligible requests complete or replay; non-replayed errors are documented and safe.
Controller loss after command submissionWorkflow record and independent role probesRestart enters reconciliation and never resubmits the role change automatically.
ONS path unavailableClient logs, pool behavior, reconnect rateClients recover through bounded validation and reconnect behavior without retaining writes to the old role.
New-primary connection surgeLogon rate, listener errors, CPU, session counts, application queue depthAdmission pacing keeps the database inside tested capacity and eventually restores the full cohort.
Former primary cannot rejoinBroker state, protection posture, incident decisionCustomer service and degraded DR posture are reported separately; the operation cannot be marked fully complete.

Measure RTO from the business event that starts the transition to verified service restoration, not only DGMGRL duration. Publish a distribution from repeated drills—median, tail, and failure causes—rather than a single best result. The drill should use the production driver, pool, connect descriptor, ONS path, authentication, and service attributes; otherwise it validates a different system.

Where It Breaks

Missing role services, single-site descriptors, and un-reinstated standbys break switchovers

Operational scenarioPhysical failure mechanismConsequenceMitigation protocol
Outcome is lost after broker submissionNetwork or workflow failure hides whether the role transition committed.An automatic retry races the completed transition or an operator.Persist submission first, disable mutation retries, probe both members independently, and resume only from reconciled roles.
Service is not role configured on both sitesThe new primary opens but Clusterware has no matching PRIMARY service definition.FAN may announce database state while the application service remains unavailable.Diff srvctl config service across sites in preflight and verify actual service placement after every transition.
Client cannot discover the new primaryConnect descriptor or ONS configuration includes only the former site, or runtime artifacts are incompatible.Pools discard sessions but repeatedly reconnect to an unavailable listener.Include both sites, test remote ONS and driver dependencies, and run production-path connection probes continuously.
In-flight work is not replay safeA request has unprotected side effects, unsupported session state, or ambiguous commit outcome.Blind application retries duplicate effects or return inconsistent results.Use Transaction Guard and Application Continuity where supported, design idempotency at business boundaries, and document non-replayable calls.
Reconnect storm exceeds target capacityThousands of pools create sessions at once after FAN or socket failure.Authentication and session initialization starve useful work on the new primary.Cap pool creation, apply jitter and admission cohorts, reserve process headroom, and stop rollout on listener or CPU guardrails.
PDB or service readiness is partialCDB role changes, but a required PDB is closed, restricted, or missing its service.Some tenants recover while others receive availability errors.Maintain an expected PDB-service manifest and verify each required mapping before admitting its cohort.
Former primary is not a healthy standbyRestart, reinstate, transport, or apply fails after the target accepts writes.Service is restored with no validated protection against the next failure.Track customer recovery and DR restoration as separate objectives, alert degraded posture, and block routine closeout until protection is restored or risk is accepted.
FSFO topology is misunderstood as quorumMultiple observers are treated as voting members, although broker selects one master and the others are backups.Operators infer split-brain protection that the observer design does not provide.Design FSFO from broker protection-mode and connectivity rules, inspect master-observer state, and test asymmetric partitions with database fencing assumptions.

September 2026 Update

OCI Full Stack Disaster Recovery can orchestrate supported OCI database, compute, storage, networking, and application resources through ordered DR plans. It is a control-plane option, not proof that an application’s connection and transaction semantics are correct. Preserve the same prechecks, ambiguous-outcome handling, service verification, and production-path synthetic test when adopting it; document which resources use native handlers and which use custom steps.

Oracle Database releases and current drivers continue to improve FAN, draining, and Application Continuity behavior, but the installed database RU and client version remain the compatibility boundary. Validate against their exact documentation and support matrix. There is no need to invent a “23ai connection director” to solve a problem that role-based services and supported clients already address.

Likewise, eBPF or service-mesh routing can change where a new TCP connection goes; it cannot relocate authenticated Oracle session state or guarantee replay of an established transaction. Use network technology for the functions it owns—reachability, policy, telemetry, and rate control—and leave database request continuity to the Oracle service and client contract.

Key Takeaways

  • READ WRITE is not application readiness: Verify broker health, former-primary standby apply, PRIMARY-role service placement, FAN delivery, and a synthetic write through the production descriptor.
  • Never auto-retry a Data Guard role transition: Disable activity retries on DGMGRL SWITCHOVER; on timeout, enter OUTCOME_UNKNOWN and probe both sites independently.
  • DNS and L4 proxies cannot migrate Oracle sessions: Use both-site ADDRESS_LIST descriptors, PRIMARY-role Clusterware services, and ONS/FAN so pools discard dead sockets cleanly.
  • Pace reconnects by cohort: Uncapped simultaneous pool reconnects can starve CPU and authentication on a cold new primary.
  • Track DR restoration separately from customer availability: A switchover is not cleanly closed until the former primary resumes redo apply as a healthy standby.

What to Do Next

  • Problem: Audit every production service for both-site discovery, role-based service definitions, FAN reception, replay eligibility, reconnect pacing, and a tested unknown-outcome runbook.
  • Solution: Build a serialized switchover state machine that uses broker validation, bounded draining, one non-retried role mutation, independent role reconciliation, and cohort-based admission.
  • Proof: Run drills that kill the controller after command submission, remove ONS, induce a reconnect surge, close one required PDB, and prevent the former primary from rejoining; retain end-to-end evidence for each outcome.
  • Action: Fix one critical service first, measure business RTO through its real driver and pool, then expand only after the new primary and restored protection both meet explicit gates.

Sources