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

ProjectionExecutor incorrectly leaves tombstones when evaluating arrays

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • Query Execution
    • ALL
    • Query 2020-11-30, Query 2020-12-14, Query 2020-12-28, Query 2021-01-11, Query 2021-01-25, Query Execution 2021-03-08, Query Execution 2021-03-22
    • 0

      The ProjectionExecutor code will leave behind a MISSING placeholder for each array element, when the projection path prefix is an array. The FastPathEligibleInclusionNode doesn't seem to produce the same issue, since it uses BSONObj. BSONObj doesn't have the tombstones issue.

      This can be fixed by returning an empty array if all the array elements have MISSING value here.

      > db.c.insert({arr: [0]})
      // This uses FastPathEligibleInclusionNode
      > db.c.aggregate([{$_internalInhibitOptimization: {}},{$project: {"arr.a" : 1}}, {$addFields: { "arr.val" : ""}}]) 
      { "_id" : ObjectId("5f5646abfb04e16296128f3f"), "arr" : [ ] }
      // This uses InclusionNode main path
      > db.c.aggregate([{$_internalInhibitOptimization: {}},{$project: {"arr.a" : 1, p: {$literal: 1}}}, {$addFields: { "arr.val" : ""}}]) 
      { "_id" : ObjectId("5f5646abfb04e16296128f3f"), "arr" : [ { "val" : "" } ], "p" : 1 }
      

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            arun.banala@mongodb.com Arun Banala
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: