dataiotech Labs
dbaguide.com · Senior DBA & SRE Diagnostic Standard v2.0
Home/Error Library/ORACLE/oracle-perf-ora-cat-21-rolling-cursor-invalidation-after-stats-gathe
Oracle
Oracle 19c, 26aiSEVERITY: P1 HIGH
6 min read
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.

Reviewed by:Senior Oracle DBA (dataiotech Labs)

Diagnostic Disambiguation Matrix

When It Occurs

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.

When This Is NOT The Error

Not an error belonging to an external database engine or unrelated subsystem; native to this catalog.

First 60 Seconds Emergency Protocol (Read-Only Safety Rule):

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.

NOTE
Entry Type (ORA-CAT-21): Cursor Condition Licensing Requirement: Core Oracle Database (EE & SE2) — no extra pack required. · Required Privileges: SELECT on V$SQL, V$SQL_SHARED_CURSOR, DBA_TAB_STATISTICS (or SELECT_CATALOG_ROLE)

▸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

  1. 1Check V$SQL_SHARED_CURSOR for ROLL_INVALID_MISMATCH='Y' and inspect FIRST_LOAD_TIME / LAST_LOAD_TIME in V$SQL.
  2. 2Correlate LAST_ANALYZED in DBA_TAB_STATISTICS to see if stats were gathered 1–5 hours prior to the regression onset.
  3. 3Compare PLAN_HASH_VALUE and DBMS_XPLAN.DISPLAY_CURSOR output between the older and newly spawned child cursors.
sql
-- 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

NEW CONCEPTENGINEERING MASTERY
Senior Interview Ready

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.

Measurable Learning Objectives:
  • 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
Senior Engineer & Architect Response:

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
Senior Engineer & Architect Response:

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
Senior Engineer & Architect Response:

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.

View Roadmap

More ORACLE Diagnostic Playbooks

Battle-tested triage guides for production incidents.

View All
dbaguide.com · Cursor Condition: Rolling Cursor Invalidation After Stats Gather · Kanıt Odaklı Teşhis Standardı
Last Updated: November 2, 2026 · Format v2.0