Decoupling Analytical Workloads: Active Data Guard and the Death of ORA-01555
Encountering an ORA-01555 error is not a database sizing deficiency; it is an architectural indicator that high-velocity transactional writes and long-running analytical queries are improperly co-located on the same physical infrastructure.
TL;DR
- Problem: Running long-running analytical scans on an active OLTP primary forces Oracle’s circular Undo tablespace to overwrite historical row pre-images before readers finish (
ORA-01555) while flooding the shared buffer cache with cold scan blocks.- Answer: Physically decouple reads and writes by routing analytical and reporting queries through CMAN-TDM or application-tier read/write pools to an Oracle Active Data Guard physical standby (
READ ONLY WITH APPLY) withTEMP_UNDO_ENABLED = TRUEandSTANDBY_MAX_DATA_DELAY.- Watch out: Standby offloading introduces apply-lag staleness (
ORA-03172), primary DDL invalidation conflicts, and Active Data Guard licensing requirements.
Situation
High-throughput Online Transaction Processing (OLTP) databases on Oracle must serve thousands of concurrent point inserts, updates, and deletes while guaranteeing statement-level and transaction-level read consistency without blocking readers. Oracle implements this guarantee through Multi-Version Concurrency Control (MVCC).
When a SELECT statement begins at a specific System Change Number (SCN_0), Oracle guarantees that every block read by that query reflects data committed as of SCN_0. If a concurrent OLTP transaction modifies a row in a block at SCN_1 > SCN_0, the kernel writes the pre-modification image into an Undo segment, records the transaction entry in the block’s Interested Transaction List (ITL), and updates the block in place. When the reader later visits that block, it compares the block header SCN against SCN_0, reads the ITL pointer, fetches the historical undo record, and constructs a Consistent Read (CR) clone in the buffer cache.
For millisecond-duration OLTP lookups, those undo records remain intact for the lifetime of the query. The architecture holds until reporting jobs, BI extracts, and ad-hoc analytical queries are pointed at the same primary database instance.
The Problem
Co-locating multi-minute or multi-hour analytical scans with continuous OLTP DML breaks two shared subsystems on the primary instance: the circular Undo tablespace and the System Global Area (SGA) buffer cache.
Four physical constraints explain why Undo tuning alone cannot resolve the conflict:
- Circular Undo Wrap-Around (
ORA-01555): Oracle manages the Undo tablespace as a ring of extents. Once active transactions finish andUNDO_RETENTIONexpires—or earlier if free space is exhausted under autoextend limits—Oracle reuses those extents for new DML. A simple rate check illustrates the sizing bound: if peak OLTP generates50 MB/sof undo and a batch report runs for7,200seconds (2 hours), the primary must retain at least50 MB/s * 7,200 s = 360,000 MB(~351.6 GB) of historical undo on top of active uncommitted undo and concurrent DML headroom. If a single unindexed analytical job stretches to 4 hours during a traffic spike, required undo doubles to over 700 GB; once any needed extent is overwritten, the query aborts withORA-01555: snapshot too old. - Delayed Block Cleanout: When a large OLTP batch modifies many data blocks and commits, Oracle updates the transaction table in the undo segment header without immediately revisiting every modified data block to clear ITL lock bytes. A later analytical scan that touches those blocks must consult the undo segment’s transaction table to verify the commit SCN. If subsequent OLTP commits have already wrapped around and overwritten that transaction table slot, the analytical query can fail with
ORA-01555almost immediately—even if zero DML runs while the query is executing. - Buffer Cache Eviction: Expanding
UNDOTBS1does nothing to protect the SGA buffer cache. Full-table and fast-full-index scans stream gigabytes of cold historical blocks through the buffer cache, evicting hot OLTP index branch blocks and active customer working sets. OLTP sessions that previously hit memory must suddenly issue physical disk reads, degrading transactional tail latency. - CPU and I/O Contention: Parallel analytical queries (
PQ) compete directly with OLTP foreground sessions for CPU run-queue slots and storage IOPS, turning a reporting spike into a customer-facing checkout slowdown.
How do platform architects eliminate ORA-01555 errors permanently while insulating primary OLTP buffer caches and CPU capacity from heavy analytical scans?
Options Considered
When ORA-01555 alerts appear in the alert log alongside rising OLTP db file sequential read waits, teams typically evaluate four options.
| Option | Mechanism | What It Solves | Where It Breaks | Decision |
|---|---|---|---|---|
Expand Undo + UNDO_RETENTION | Add terabytes of storage to UNDOTBS and raise UNDO_RETENTION | Extends the time window before expired undo extents are overwritten | Does not stop SGA buffer cache eviction, CPU contention, or delayed block cleanout wrap-around | Rejected as standalone fix |
RETENTION GUARANTEE | Force Oracle never to steal unexpired undo extents (ALTER TABLESPACE ... RETENTION GUARANTEE) | Prevents ORA-01555 from premature extent stealing | When undo fills, OLTP INSERT/UPDATE/DELETE statements fail with ORA-30036 | Rejected; unacceptable OLTP blast radius |
| Batch ETL / Data Pump Offload | Export snapshots periodically to a separate data warehouse | Isolates long-running BI from primary SGA and undo | Introduces hours of data staleness; export jobs themselves still read the primary | Deferred for near-real-time operational reporting |
| Active Data Guard Read-Write Split | Offload read-only queries to a physical standby in READ ONLY WITH APPLY mode | Isolates SGA, CPU, IOPS, and Temporary Undo while keeping low replication lag | Requires Active Data Guard licensing and explicit lag/DDL governance | Chosen for operational analytics and reporting |
Enabling RETENTION GUARANTEE on the primary Undo tablespace is particularly dangerous: it inverses the failure mode so that a runaway reporting query causes production OLTP writes to fail with ORA-30036: unable to extend segment by ... in undo tablespace. Batch ETL remains appropriate for multi-year warehouse aggregations, but operational reporting and real-time dashboards need fresher data without touching the primary SGA. Active Data Guard solves both problems simultaneously by replaying redo onto independent compute and memory.
The Active Data Guard Read-Write Decoupling Architecture
The recommended architecture enforces physical compute, memory, and undo isolation between transactional writes and analytical reads. The primary database handles only OLTP DML and latency-sensitive point lookups. Redo streams continuously via Data Guard transport (NSS/RFS processes) to one or more Active Data Guard physical standbys running in READ ONLY WITH APPLY mode, where the Managed Recovery Process (MRP) applies changes in real time.
Three architectural mechanisms make the split transparent and safe for applications:
- Role-Pinned Database Services: Using
srvctl, administrators definesvc_oltp_primarywith-role PRIMARYandsvc_analytics_rowith-role PHYSICAL_STANDBY. Clusterware starts each service only on the database currently holding that role, so a Data Guard switchover or failover automatically moves services to the right hosts. - Standby Temporary Undo (
TEMP_UNDO_ENABLED = TRUE): Analytical queries frequently materialize global temporary tables or spill hash joins and sorts. SettingTEMP_UNDO_ENABLED = TRUEon the standby redirects temporary-table undo into the standby’s local temporary tablespace rather than generating undo or redo dependencies against the primary. - Freshness Bounds and Proxy Routing: Applications route traffic either through Oracle Connection Manager in Traffic Director Mode (
CMAN-TDM) or through an application-tier routingDataSource(for example, Spring’sAbstractRoutingDataSourceinspecting@Transactional(readOnly = true)). Sessions on the standby enforceSTANDBY_MAX_DATA_DELAYso queries abort cleanly withORA-03172rather than serving stale data beyond SLA. When geographical separation between the primary and reporting regions adds network round-trip latency, an Oracle Far Sync instance placed near the primary receives synchronous redo locally and ships asynchronously to the remote Active Data Guard standby, keeping primary commit latency isolated from WAN distance.
1. Role-Pinned Services and Standby Configuration
Define the role-aware services in Clusterware and configure standby read consistency controls:
# Primary OLTP service (runs only when database is in PRIMARY role)
srvctl add service -db PRODDB \
-service svc_oltp_primary \
-role PRIMARY \
-notification TRUE \
-failovertype TRANSACTION \
-commit_outcome TRUE
# Analytical read-only service (runs only when database is PHYSICAL_STANDBY)
srvctl add service -db PRODDB \
-service svc_analytics_ro \
-role PHYSICAL_STANDBY \
-notification TRUE \
-clbgoal LONG \
-rlbgoal THROUGHPUT
srvctl start service -db PRODDB -service svc_oltp_primary
On the Active Data Guard standby, ensure Standby Redo Logs (SRLs) are configured at the same size as the primary online redo logs with at least one more group per primary thread (online_groups + 1) so real-time apply never stalls waiting for log archival. Then enable local temporary undo and open the database in READ ONLY WITH APPLY:
-- Isolate temporary table undo on the standby's local TEMP tablespace
ALTER SYSTEM SET TEMP_UNDO_ENABLED = TRUE SCOPE=BOTH;
-- Open standby read-only and start Real-Time Apply
ALTER DATABASE OPEN READ ONLY;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
-- Enforce session-level lag SLA (e.g., via logon trigger for svc_analytics_ro)
-- Raises ORA-03172 if apply lag exceeds 15 seconds
ALTER SESSION SET STANDBY_MAX_DATA_DELAY = 15;
2. Oracle Connection Manager (cman.ora) Traffic Director Mode
Configure CMAN-TDM (TDM = YES) to proxy and filter client connections by target service name and enforce session timeouts:
cman_router =
(CONFIGURATION =
(ADDRESS = (PROTOCOL = TCP)(HOST = cman-proxy.corp.internal)(PORT = 1521))
(PARAMETER_LIST =
(TDM = YES)
(MAX_GATEWAY_PROCESSES = 16)
(MIN_GATEWAY_PROCESSES = 4)
)
(RULE_LIST =
(RULE =
(SRC = 10.0.0.0/8)
(DST = *)
(SRV = svc_analytics_ro)
(ACT = accept)
(ACTION_LIST = (SESSION_TIMEOUT = 14400))
)
(RULE =
(SRC = 10.0.0.0/8)
(DST = *)
(SRV = svc_oltp_primary)
(ACT = accept)
(ACTION_LIST = (SESSION_TIMEOUT = 3600))
)
)
)
3. Application-Tier Read-Write Splitting (Spring / HikariCP)
For microservices using Spring transaction boundaries, route @Transactional(readOnly = true) methods to the standby pool while defaulting all write and read-your-writes paths to the primary pool:
public class TransactionRoutingDataSource extends AbstractRoutingDataSource {
@Override
protected Object determineCurrentLookupKey() {
boolean isReadOnly = TransactionSynchronizationManager.isCurrentTransactionReadOnly();
return isReadOnly ? DataSourceType.READ_ONLY_STANDBY : DataSourceType.READ_WRITE_PRIMARY;
}
}
Ensure that TransactionRoutingDataSource wraps a LazyConnectionDataSourceProxy in Spring so the transaction’s readOnly flag is evaluated before a physical JDBC connection is borrowed from HikariCP.
How It Rolls Out
Roll out read-write decoupling in four gated phases so licensing, redo transport, and switchover behavior are verified before production BI traffic moves.
- Phase 1 — Standby Preparation and Licensing Verification: Confirm Active Data Guard licensing entitlement, verify Standby Redo Logs (SRLs) match or exceed primary online redo log groups, set
TEMP_UNDO_ENABLED = TRUE, and open the standby inREAD ONLY WITH APPLY.- Validation gate: Query
V$DATABASE(OPEN_MODE = 'READ ONLY WITH APPLY') andV$DATAGUARD_STATS(apply lagwithin target SLA). - Rollback: Cancel MRP, reopen in
MOUNTstate, and restart MRP without real-time query if licensing or stability issues appear.
- Validation gate: Query
- Phase 2 — Role-Pinned Service Creation: Create
svc_oltp_primary(-role PRIMARY) andsvc_analytics_ro(-role PHYSICAL_STANDBY) viasrvctland test a planned Data Guard switchover in staging.- Validation gate: Confirm services start automatically on the correct post-switchover hosts without manual intervention.
- Rollback: Stop and remove the new services via
srvctl; existing connections continue using legacy services.
- Phase 3 — Proxy Routing and Lag SLA Enforcement: Deploy
CMAN-TDMbehind a load balancer and enableSTANDBY_MAX_DATA_DELAYin reporting sessions (or a logon trigger scoped tosvc_analytics_ro). Test application fallback behavior whenORA-03172is raised.- Validation gate: Simulate standby apply lag in staging and confirm
ORA-03172triggers either controlled retry or primary fallback for critical reads. - Rollback: Point client TNS aliases directly to the primary SCAN listener and bypass
CMAN-TDM.
- Validation gate: Simulate standby apply lag in staging and confirm
- Phase 4 — Analytical Workload Cutover: Migrate BI dashboards, scheduled reports, and long-running ad-hoc SQL clients from the primary service to
svc_analytics_ro, starting with the longest-running queries first.- Validation gate: Confirm
ORA-01555errors cease on the primary alert log and primary buffer cache hit ratios stabilize without full-table-scan spikes. - Rollback: Revert the BI tool’s service name back to the primary service while keeping
TEMP_UNDO_ENABLEDintact.
- Validation gate: Confirm
In Practice
Based on how Oracle Data Guard, MVCC, and CMAN-TDM operate in production:
- Why standbys avoid primary undo wrap-around: On an Active Data Guard standby,
MRPapplies redo sequentially from the primary, and read-only sessions reconstruct consistent views using the standby’s own SCN progression without competing against local OLTPINSERT/UPDATE/DELETEundo allocation. EnablingTEMP_UNDO_ENABLED = TRUEensures that sorting, hash-join spills, and global temporary table writes on the standby stay inside local temporary segments. - Bounding stale reads with
STANDBY_MAX_DATA_DELAY: When a session setsALTER SESSION SET STANDBY_MAX_DATA_DELAY = 15, Oracle checksapply lagbefore executing each query. If lag exceeds 15 seconds, the query fails immediately withORA-03172: STANDBY_MAX_DATA_DELAY of 15 seconds exceededrather than silently returning stale balances. Applications that require strict read-your-writes immediately after a mutation must still pin post-write reads tosvc_oltp_primaryrather than relying on an asynchronous standby. - Handling stray writes on a read-only standby: Any
INSERT,UPDATE, orDELETEaccidentally routed tosvc_analytics_rofails withORA-16000: database or pluggable database open for read-only access. Starting in Oracle 19c, settingADG_REDIRECT_DML = TRUEtransparently tunnels occasional DML statements back to the primary over an internal link and waits for redo apply before returning—useful for legacy reporting tools that write small audit rows, though unsuitable for heavy OLTP writes (and unsupported inside XA transactions). - Monitoring redo transport and lag: Query
V$DATAGUARD_STATSon the standby fortransport lagandapply lag, and queryV$REDO_DEST_RESP_HISTOGRAMon the primary alongside transport wait events (LNS wait on SENDREQin older releases,NSSsync /TTnnasync transport waits in 12c+) to catch network bottlenecks early.
Where It Breaks
Decoupling reads onto a physical standby shifts failure modes from local undo exhaustion to replication lag, DDL coordination, and proxy availability.
| Condition | Breaks how | Detect | Mitigate |
|---|---|---|---|
| Standby apply lag spike | Burst primary DML or slow standby I/O delays MRP; reads return stale data or abort with ORA-03172. | Query V$DATAGUARD_STATS (apply lag) and alert on ORA-03172 spikes. | Set STANDBY_MAX_DATA_DELAY per SLA; route read-your-writes sessions to svc_oltp_primary. |
Primary partition DROP or TRUNCATE | Destructive partition DDL invalidates segments currently scanned by a standby query, raising ORA-01555 or ORA-08103. | Alert on ORA-01555 / ORA-08103 on the standby during maintenance windows. | Schedule partition drops outside peak BI windows; use ALTER SESSION SET DDL_LOCK_TIMEOUT on primary. |
| Unlicensed Active Data Guard usage | Opening a physical standby READ ONLY while MRP is active triggers ADG license feature tracking. | Audit DBA_FEATURE_USAGE_STATISTICS for Active Data Guard. | Verify ADG license entitlements before opening any standby in READ ONLY WITH APPLY. |
Standby SGA or TEMP exhaustion | Concurrent multi-pass hash joins or huge table scans thrash standby SGA and fill TEMP (ORA-01652). | Monitor ORA-01652 and standby V$TEMPSEG_USAGE / AWR wait events. | Enforce Database Resource Manager (DBRM) consumer groups and size standby TEMP for peak concurrency. |
Single CMAN-TDM proxy outage | A single proxy VM failure drops all routed primary and standby client connections simultaneously. | Health-check failures on port 1521 at the proxy tier. | Deploy CMAN-TDM in an active-active pair behind a network load balancer with health probes. |
| Stray DML routed to standby | Misconfigured application pool sends INSERT/UPDATE to svc_analytics_ro and hits ORA-16000. | Application error logs showing ORA-16000 on read-only pools. | Fix @Transactional(readOnly = true) boundaries; enable ADG_REDIRECT_DML = TRUE only for occasional audit writes. |
| Redo transport congestion | Network packet loss or small DEFAULT_SDU_SIZE stalls SYNC commits (log file sync) or widens ASYNC lag. | Monitor V$REDO_DEST_RESP_HISTOGRAM and NSS/LNS wait on SENDREQ events. | Separate redo transport onto dedicated NICs, tune DEFAULT_SDU_SIZE=32767, and place SRLs on fast storage. |
Key Takeaways
- Undo sizing cannot fix cache pollution: Expanding
UNDOTBSand raisingUNDO_RETENTIONonly delaysORA-01555wrap-around; it never stops analytical full-table scans from evicting hot OLTP blocks from the primary SGA. - Never use
RETENTION GUARANTEEon an OLTP primary: Guaranteeing undo retention for long-running queries converts reporting failures intoORA-30036write outages for customer-facing OLTP transactions. - Role-pinned services keep Data Guard switchovers automatic: Binding
svc_oltp_primarytoPRIMARYandsvc_analytics_rotoPHYSICAL_STANDBYviasrvctlensures traffic follows the active role without manual TNS edits. - Enforce freshness explicitly with
STANDBY_MAX_DATA_DELAY: Rather than letting dashboards silently read lagging data, bound staleness at the session level (ORA-03172) and pin read-your-writes sessions to the primary. - Verify licensing and DDL windows before cutover: Active Data Guard requires explicit licensing for
READ ONLY WITH APPLY, and primaryDROP/TRUNCATE PARTITIONoperations must still be coordinated around active standby scans.
What to Do Next
- Problem: Co-locating long-running analytical queries with high-velocity OLTP writes on a single Oracle primary exhausts circular undo (
ORA-01555) and evicts hot OLTP buffers from the SGA. - Solution: Offload analytical and reporting workloads to an Active Data Guard physical standby using role-pinned
srvctlservices,TEMP_UNDO_ENABLED = TRUE,STANDBY_MAX_DATA_DELAY, andCMAN-TDMor application-tier read/write routing. - Proof: Primary
ORA-01555alerts drop to zero, primary buffer cache hit ratios stabilize without full-scan eviction, andV$DATAGUARD_STATSconfirmsapply lagstays within yourSTANDBY_MAX_DATA_DELAYthreshold. - Action: Audit your primary AWR “SQL ordered by Elapsed Time” report this week, verify Active Data Guard licensing on your existing physical standby, and migrate your top long-running reporting queries onto a
PHYSICAL_STANDBYservice.