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

Make change stream mixed-collator check more robust

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Fully Compatible
    • ALL
    • QE 2021-09-20

      In SERVER-59426, we forbid change streams from engaging in oplog rewrites in cases where the user specified a non-simple collation. However, in SERVER-58514 we discovered that this could still happen and had to add in specific checks to avoid it.

      The issue here is that our current check is based on whether the collator set on the ExpressionContext is nullptr or not (see here and here). This works OK for the first time we attempt to do optimization, which runs with the user-specified collation. However, we then temporarily change the collation on the ExpCtx to nullptr right before attempting to absorb the initial $match into the query system. During that process, we call optimize() again with the collation now set to nullptr, which bypasses our checks and incorrectly rewrites the user's filters into the oplog.

      We must ensure that, once we see a non-simple collator on the ExpCtx during optimization, any future attempts at optimization will be abandoned, regardless of what the collation is at that point. We should also remove the additional code added to handled this in SERVER-58514.

            Assignee:
            justin.seyster@mongodb.com Justin Seyster
            Reporter:
            bernard.gorman@mongodb.com Bernard Gorman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: