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

Update MatchExpression optimizations to respect BSON lifetime

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0, 8.0.0-rc6
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • v8.0
    • QO 2024-05-13, QO 2024-05-27

      This test in particular demonstrates the problem when we apply to change pending for SERVER-87277 (delete backing BSONObj for ComparisonMatchExpression).

      {$or: [{a: 1}, {a: 1}]}

      Will first optimize to

      {a: {$in: [1, 1]}}
      

      as part of the $or -> $in rewrite. This rewrite currently will construct new BSON for each element of the $in operand. Then we recursively invoke MatchExpression optimization, which ends up destroying the $in and the backing BSON for [1, 1].

      The recursive invocation will end up in the $in -> $eq rewrite, which currently initializes the $eq with a BSONElement.

       

       

            Assignee:
            matt.olma@mongodb.com Matt Olma
            Reporter:
            ben.shteinfeld@mongodb.com Ben Shteinfeld
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: