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

Incorrect bucket-level filter optimization when some events in the bucket are missing the field

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.2.1, 7.3.0-rc0, 6.0.13, 7.0.6
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • v7.2, v7.0, v6.0
    • QI 2023-12-25, QI 2024-01-08
    • 135

      db.createCollection("fuzzer_coll", {timeseries: {"timeField" : "time", "metaField" : "tag"}})
      db.fuzzer_coll.insertMany([
           {_id: 0, time: new Date("2023-08-28T02:02:48.409Z"), tag: 0, val: 0},
           {_id: 1, time: new Date("2023-08-28T02:02:56.819Z"), tag: 0, obj: ISODate("2019-05-28T04:59:48.151Z")}, 
      ])
       
      db.fuzzer_coll.aggregate([{$match: {$expr: {$gte: ["any string", "$obj"]}}}])
      // returns nothing
       
      db.adminCommand({configureFailPoint: 'disablePipelineOptimization', mode: 'alwaysOn'})
      db.fuzzer_coll.aggregate([{$match: {$expr: {$gte: ["Refined revolutionize", "$obj"]}}}])
      // returns: { "time" : ISODate("2023-08-28T02:02:48.409Z"), "tag" : 0, "_id" : 0, "val" : 0 }
      // same result when running this query on a non-ts collection with the same 2 documents.
      

      The bucket-level filter is

      {"control.min.obj": {"$_internalExprLte" : "any string"}}
      

      The problem is repro with other types, not just dates and strings, as long as the original expression in the filter isn't type-bracketing (such as comparisons inside $expr).

            Assignee:
            irina.yatsenko@mongodb.com Irina Yatsenko (Inactive)
            Reporter:
            irina.yatsenko@mongodb.com Irina Yatsenko (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: