ExportXMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • DB Integration & Observability
    • Fully Compatible
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Deliverable

      Make the option user-facing and install the stage.

      User-facing option

      • Add a showErrorsAsEvents boolean to the $changeStream IDL spec.
      • Gate it behind featureFlagChangeStreamEmitErrorEvents (FCV-gated and checked at parse time).
      • Normalize an explicit false out of the query shape.
      • Forward the option from shell watch().

      Stage injection

      Add change_stream::pipeline_helpers::addErrorConversionStageIfNeeded(Pipeline&) with the following behavior:

      • No-op unless changeStreamShowsErrorsAsEvents() is true.
      • Idempotent.
      • Adds the stage as the final source.

      Call it at these sites:

      • Data-bearing node: run_aggregate.cpp, in prepareExecutorsForPipeline, before plan_executor_factory::make.
      • Router: cluster_aggregation_planner.cpp, in buildClusterCursor, before RouterStagePipeline.

      Executor cleanup

      Remove error conversion from the executors:

      • In PlanExecutorPipeline::_tryGetNext(), remove the gap-release / tryBuildErrorEvent / 534 catches.
      • In RouterStagePipeline::next(), remove the gap-release / tryBuildErrorEvent / 534 catches.
      • Keep the flag-independent ChangeStreamStartAfterInvalidate catch.
      • Keep the serialization boundary (_trySerializeToBson / _validateAndConvertToBSON).

      Files

      • src/mongo/db/pipeline/document_source_change_stream.idl
      • src/mongo/db/query/query_feature_flags.idl
      • src/mongo/shell/mongo.js
      • src/mongo/db/pipeline/change_stream_pipeline_helpers.{h,cpp}
      • src/mongo/db/commands/query_cmd/run_aggregate.cpp
      • src/mongo/s/query/planner/cluster_aggregation_planner.cpp
      • src/mongo/db/pipeline/plan_executor_pipeline.cpp
      • src/mongo/s/query/exec/router_stage_pipeline.cpp

      Tests

      • Parser / feature gate / FCV: option is accepted only when the flag is on; false is normalized out.
      • Injection unit: stage is added only for opted-in change streams and is idempotent.
      • Plan-executor / router unit: verify no conversion remains in the executors.
      • Replica-set integration:
        • error_events_formerly_fatal.js
        • error_events_internal.js
        • error_events_resume.js

            Assignee:
            Unassigned
            Reporter:
            Nicola Cabiddu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: