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

Empty collection causes invalid selectivity assertion in CBR

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • ALL
    • QO 2025-02-03

      > db.adminCommand({setParameter:1, planRankerMode: "heuristicCE"})
      > db.createCollection("foo")
      > db.foo.find({a: 0})
      MongoServerError: Invalid Selectivity value > maxValue: (inf > 1) 

      This occurs because we populate the inputCard to the CardinalityEstimator with 0. Then when calculating the selectivity of the a = 0 predicate, we end up with a division by 0.

      In this ticket we should:

      • Detect this case in the estimation of MatchExpression
      • Add assertion to division operator to surface a divide by 0 error earlier
      • Audit instances of division to ensure we check 0 case

            Assignee:
            ben.shteinfeld@mongodb.com Ben Shteinfeld
            Reporter:
            ben.shteinfeld@mongodb.com Ben Shteinfeld
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: