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

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • 4.0.5, 4.1.5
    • Affects Version/s: 4.0.0, 4.1.4
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Fully Compatible
    • ALL
    • v4.0
    • 45

      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: {}}])
      

            Assignee:
            charlie.swanson@mongodb.com Charlie Swanson
            Reporter:
            charlie.swanson@mongodb.com Charlie Swanson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: