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

Copy only BSON types during yielding of SBE plans

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Blocker - P1 Blocker - P1
    • 6.0.0-rc4, 6.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL
    • v6.0
    • QE 2022-05-02
    • 155

      Imagine we have the following SBE plan:

      unwind s13 s14
      project [s13 = if (getArraySize (s12) > 0, s12, [null])]
      group [] [s12 = addToSet (s10)]
      // Some part of the tree producing s10
      

      Basically, we are collecting some values into ArraySet in s12, make a reference to s12 with s13 and then unwind ArraySet from s13.

      Now imagine that after unwinding first N elements, yield happens. All values in the tree will be copied, including the value behind s13. Unwind will update its reference to ArraySet to point to the freshly copied value and skip first N elements. The problem is, we have no guarantee that these N elements are in fact the same elements produced before, since ArraySet does not have ordering guarantees.

      Since all non-BSON values are always owned by the SBE tree, it makes sense to copy only BSON values during yielding. This will also solve the problem outlined above.

            Assignee:
            nikita.lapkov@mongodb.com Nikita Lapkov (Inactive)
            Reporter:
            nikita.lapkov@mongodb.com Nikita Lapkov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: