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

    • Bug
    • Status: Closed
    • Critical - P2
    • Resolution: Fixed
    • 4.0.0, 4.1.4
    • 4.0.5, 4.1.5
    • Aggregation Framework
    • None
    • Fully Compatible
    • ALL
    • v4.0
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: