Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-84369

Ineligible query reuses plan cache entry for a COUNT_SCAN (SBE only)

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.2.1, 7.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL
    • v7.2, v7.1
    • QO 2023-12-25, QO 2024-01-08, QO 2024-01-22
    • 135

      See BF-31072 for a detailed description/repro of the problem. The following pipeline (A) is ineligible for a COUNT_SCAN:
       

      [{ $match: {"num": {$not: {$gt: NumberDecimal("9.999999999999999999999999999999999E+6144")}}} },
      {$count: "num"}]

      However, when this pipeline (B) runs first:

      [{$match: {"num": {$not: {$gt: NumberDecimal("Infinity")}}}},        {$count: "num"}]

      B uses a COUNT_SCAN, and generates a plan-cache entry, which A then (incorrectly) uses. Both queries should match/count an empty document {}; however, B does not count it when using a COUNT_SCAN.

      This is only reproducible with SBE enabled, plan cache on, and match expression optimization enabled.
       

            Assignee:
            ruoxin.xu@mongodb.com Ruoxin Xu
            Reporter:
            alya.berciu@mongodb.com Alya Berciu
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: