agg_stage_coverage.js fails "$planCacheStats expected to return documents" when balancer migrates the collection

XMLWordPrintableJSON

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

      The core jstest jstests/core/timeseries/query/agg_stage_coverage.js fails intermittently in balancer-enabled sharded passthroughs with:

      assert failed : $planCacheStats expected to return documents on timeseries collections.
        @jstests/core/timeseries/query/agg_stage_coverage.js:349:11
        @jstests/core/timeseries/query/agg_stage_coverage.js:335:36
      

      Root cause. The test seeds the plan cache with a query that has two competing plans, then later iterates over all aggregation stages and asserts that [{$planCacheStats: {]}} returns at least one entry.

      In suites running with the balancer enabled, the balancer can perform a moveCollection (implemented as resharding) on test.agg_stage_coverage at any time. Migrating/moving a collection clears the plan cache on the owning shard, so by the time the loop reaches the $planCacheStats case the cache is empty and the assert(result.length > 0) fails.

      Observed sequence from the failing run:

      • 03:50:43 – collection created, documents inserted, plan cache seeded.
      • 03:50:44.4 – 45.66 – balancer runs moveCollection ("provenance":"balancerMoveCollection",
        "Resharding complete" at 03:50:45.661), clearing the plan cache.
      • 03:50:45.686 – the loop reaches $planCacheStats, sees an empty cache, and the assertion fails.

      The IngressRequestRateLimitExceeded messages in the log are the balancer's own throttled internal config reads and are unrelated to the failure.

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

              Created:
              Updated:
              Resolved: