JOO/CBR cardinality snapshot mismatch triggers tassert 9274202

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • ALL
    • QO 2025-02-17
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Problem

      A concurrent delete between JOO sampling and CBR single-table planning can leave the sampling estimator at cardinality N while CBR uses N-1. Sampling CE then computes a selectivity greater than 1 and triggers tassert 9274202.

      Reproduction

      * Enable join optimization and disable the join plan cache.
      * Create indexed collections with 100 documents.
      * Pause at sleepWhileCbrPlanningForJoinOptimization.
      * Delete one document from the base collection.
      * Resume planning.

      Observed failure:

      Cardinality: 100, Source: Code must be < Cardinality: 99, Source: Metadata to produce selectivity
      

      A deterministic reproducer is in jstests/noPassthrough/query/joins/cbr_joo_cardinality_race_repro.js.

      Root Cause

      JOO captures numRecords() when constructing the sampling estimator. CBR later captures numRecords() while constructing QueryPlannerParams, producing inconsistent cardinality snapshots.

      Related Issues

      * SERVER-128328 — sample cardinality authority can become stale.
      * SERVER-123925 — JOO cardinality overestimation.
      * SERVER-132009 — JOO debuggability improvements.

            Assignee:
            Matt Olma
            Reporter:
            Jess Balint
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: