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

mongos does not correctly enforce that a change stream must be the first stage

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Fixed
    • Affects Version/s: 4.0.0, 4.1.4
    • Fix Version/s: 4.0.5, 4.1.5
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Requested:
      v4.0
    • Linked BF Score:
      45

      Description

      The $changeStream stage is implemented by parsing as a single stage, but expanding into several internal-only stages for execution. One of those stages (DocumentSourceOplogMatch) is responsible for enforcing that it must be the first stage in the pipeline.

      Unfortunately, there are some cases where we never send a $changeStream to a shard, and so we never create a DocumentSourceOplogMatch, and so it is never enforced that it must be the first stage in the pipeline. For example, the following pipeline should be illegal, but the $changeStream stage stays on mongos, because the $sort stage forces a split in the pipeline and keeps the merging half on mongos:

      db.sharded_collection.aggregate([{$sort: {x: 1}}, {$changeStream: {}}])
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: