Rolling Cursor Invalidation After Stats Gather [Cursor Condition]Cursor Condition · Rolling Cursor Invalidation After Stats Gather
The standard behavior of DBMS_STATS (NO_INVALIDATE => DBMS_STATS.AUTO_INVALIDATE) that staggers invalidation of dependent cursors across _OPTIMIZER_INVALIDATION_PERIOD (default 5 hours) rather than invalidating all cursors simultaneously. While protective against hard parse storms, rolling invalidation means a bad statistics refresh can trigger a delayed SQL Plan Regression hours after the maintenance window closed.
Diagnostic Disambiguation Matrix
Verified operational error scenario under Oracle 19c, 26ai: The standard behavior of DBMS_STATS (NO_INVALIDATE => DBMS_STATS.AUTO_INVALIDATE) that staggers invalidation of dependent cursors across _OPTIMIZER_INVALIDATION_PERIOD (default 5 hours) rather than invalidating all cursors simultaneously. While protective against hard parse storms, rolling invalidation means a bad statistics refresh can trigger a delayed SQL Plan Regression hours after the maintenance window closed.
Not an error belonging to an external database engine or unrelated subsystem; native to this catalog.
The error string is a symptom, not the root cause. Do not restart database servers blindly! Execute the read-only diagnostic queries below to determine the actual failure mode before attempting session terminations or configuration changes.
▸1. Description & Context
The standard behavior of DBMS_STATS (NO_INVALIDATE => DBMS_STATS.AUTO_INVALIDATE) that staggers invalidation of dependent cursors across _OPTIMIZER_INVALIDATION_PERIOD (default 5 hours) rather than invalidating all cursors simultaneously. While protective against hard parse storms, rolling invalidation means a bad statistics refresh can trigger a delayed SQL Plan Regression hours after the maintenance window closed.
Severity Context: Medium / High — Creates a false sense of security during short post-change checks, allowing a bad stats refresh to surface as a surprise plan regression hours later during peak load.
▸2. Possible Causes (Confirm Root Cause via Evidence)
- •Possible cause (expected design behavior — verify via telemetry): Automated or manual DBMS_STATS running with AUTO_INVALIDATE staggering cursor reparses over up to 5 hours.
- •Possible cause: Healthy performance persisting immediately post-change on the old child cursor, followed hours later by a new child (ROLL_INVALID_MISMATCH='Y') compiling a regressed plan.
▸3. Read-Only Diagnostic Steps
- 1Check V$SQL_SHARED_CURSOR for ROLL_INVALID_MISMATCH='Y' and inspect FIRST_LOAD_TIME / LAST_LOAD_TIME in V$SQL.
- 2Correlate LAST_ANALYZED in DBA_TAB_STATISTICS to see if stats were gathered 1–5 hours prior to the regression onset.
- 3Compare PLAN_HASH_VALUE and DBMS_XPLAN.DISPLAY_CURSOR output between the older and newly spawned child cursors.
-- ORA-CAT-21 | Core Oracle Database (EE & SE2) — no extra pack required. | Syntax-Reviewed (Not Runtime-Tested)
-- READ-ONLY | License-free core V$ view
SELECT s.sql_id, s.child_number, s.plan_hash_value,
s.first_load_time, s.last_load_time,
sc.roll_invalid_mismatch, s.executions,
ROUND(s.elapsed_time/GREATEST(s.executions,1)/1e6, 4) AS avg_elap_s
FROM v$sql s
JOIN v$sql_shared_cursor sc
ON s.sql_id = sc.sql_id AND s.child_number = sc.child_number
WHERE sc.roll_invalid_mismatch = 'Y'
ORDER BY s.last_load_time DESC
FETCH FIRST 20 ROWS ONLY;▸4. Controlled Remediation Options
- •Protect critical SQL with SQL Plan Baselines prior to stats refreshes (or enable Auto SPM / Real-Time SPM on 19c RU 19.22+ / 26ai EE).
- •Extend post-change observation across the full 5-hour rolling invalidation window and first peak business cycle.
- •If a bad child cursor already appeared, restore stats via DBMS_STATS.RESTORE_TABLE_STATS or enforce the prior good plan via SQL Plan Baseline.
▸5. Related Terms & References
- •Related Terms: Cursor Invalidation, Child Cursor, Optimizer Statistics, SQL Plan Regression, SQL Plan Baseline
- •Main Technical Guide: Oracle SQL Plan Regression: Detection, Diagnosis and Stabilization
- •Official Documentation: Oracle Documentation
ORACLE Diagnostic Standards, Operational Reliability, and Interview Readiness.
This error is not merely a config typo; it is a lesson in consistency models, concurrency architectures, and capacity planning.
- Articulate error symptoms, distinguishing diagnostics, and safe recovery steps.
- Implement architectural safeguards to permanently eliminate root causes.
What Senior Interviews Ask About This Error?
Q1When this error (Rolling Cursor Invalidation After Stats Gather [Cursor Condition]) surfaces in production, what must be inspected within the first 60 seconds?Mid
Before restarting servers blindly, inspect active sessions, locks, and recent engine logs to identify the true failure mode.
Q2Which metrics should be integrated into alerting to prevent recurrence of this issue?Senior
Set up early warning metrics targeting connection pools, memory grants, disk headroom, or lock queues with actionable thresholds.
Q3How should applications defensively guard against this database failure?Junior
Implement idempotent retry loops with backoff, strict query timeouts, verified connection pool bounds, and structured error logging.
Senior DBA & SRE Career Roadmap
Explore database reliability milestones, incident response protocols, and architectural leadership.
More ORACLE Diagnostic Playbooks
Battle-tested triage guides for production incidents.
Oracle ORA-01653: Tablespace Extension & Step-by-Step Fix
Distinguishing ORA-01653, 01654, and 01652, tablespace capacity monitoring, datafile autoextend, and safe sizing with MAXSIZE.
Oracle ORA-00001: unique constraint violated Triage & Fix
Troubleshooting unique key collisions caused by out-of-sync sequences and bulk imports; sequence fast-forwarding and DML error logging.
Oracle ORA-00060: deadlock detected while waiting for resource Triage
Root cause analysis of cross-dependency deadlocks and missing foreign key index table locks via trace logs and serialized DML execution.