cbr_shard_filter.js fails when featureFlagGetExecutorDeferredEngineChoice is off because an empty shard triggers zero-CE fallback to multiplanning

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc5
    • Affects Version/s: 9.0.0-rc4
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • ALL
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Problem

      jstests/noPassthrough/query/cbr/cbr_shard_filter.js fails with Error: assert failed in assertPlanCosted on the roll_back_incremental_feature_flags_no_passthrough_qemp_ifr_batch1 suite (v9.0-staging, commit 2b664c9e36b): the plan rooted at SHARDING_FILTER returned by one shard has no costEstimate in its explain output.

      Root Cause

      The test shards test.cbr_shard_filter on {_id: "hashed"} across 2 shards but inserts only a single document, so one shard owns an empty chunk. On the empty shard:

      • Collection cardinality is 0, sourced from Metadata, and clampZeroEstimate intentionally does not clamp Metadata-sourced zeros.
      • The zero-CE fallback added by SERVER-133362 (CardinalityEstimator::estimate) sees STAGE_IXSCAN with ce == zeroCE and returns Status(ErrorCodes::ZeroCEEstimate), so CBR abandons costing the plan and falls back to multiplanning.
      • The plan reaches explain uncosted: FETCH/SHARDING_FILTER have no estimates and the IXSCAN keeps the uninitialized QSNEstimate sentinel cost (1.797e+308).
      • getAllPlans(explain).forEach(assertPlanCosted) then fails on the empty shard's plan.

      The failure only reproduces when featureFlagGetExecutorDeferredEngineChoice is off (as in the IFR rollback suite); with the flag on, the test exits early via its TODO SERVER-130179 skip, which is why regular variants did not catch it. SERVER-133362 updated ~15 CBR tests for the new fallback semantics but missed this sharded one, where the empty shard is created implicitly.

      Fix

      Make the test guarantee both shards own data, preserving its intent (CBR must cost plans containing SHARDING_FILTER):

      • Insert 20 documents with sequential _id values instead of 1, so hashed sharding distributes documents to both shards.
      • Assert each shard owns at least one document, so the precondition is explicit if data distribution ever changes.

            Assignee:
            Matt Olma
            Reporter:
            Matt Olma
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: