ExportXMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.1.0-rc0, 9.1.0-rc1025
    • Affects Version/s: None
    • Component/s: None
    • None
    • DB Integration & Observability
    • Fully Compatible
    • QE 2026-10-26, QE 2026-11-23
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      mplement the top-level conversion stage as a registered DocumentSource and execution-stage pair. Do not inject the stage into any pipeline yet.

      Stage Definition

      DocumentSourceChangeStreamConvertErrors

      • Stage name: $_internalChangeStreamConvertErrors
      • Internal stage; excluded from the query shape.
      • Constraints:
        • kChangeStreamStage
        • kReceivingHostOnly
        • Streaming
        • Not swappable with $match or single-document transforms

      ChangeStreamConvertErrorsStage::doGetNext()

      • Drain paused input.
      • On delivery, clear activeChangeStreamEvent and activeChangeStreamErrorSource.
      • Handle exceptions as follows:
        • ChangeStreamErrorEventBypass (534): return the stashed router event.
        • ChangeStreamHistoryLost: return the pending resume gap.
        • DBException: call tryBuildErrorEvent; if no event can be built, rethrow.

      Supporting Changes

      • Add these ExpressionContext accessors:
        • clearActiveChangeStreamEvent
        • clearActiveChangeStreamErrorSource
        • releasePendingChangeStreamResumeGap
        • releasePendingChangeStreamRouterErrorEvent
      • Add change_stream::tryBuildErrorEvent.
      • Add error codes 532, 533, and 534.

      Files

      • src/mongo/db/pipeline/document_source_change_stream_convert_errors.{h,cpp}
      • src/mongo/db/exec/agg/change_stream_convert_errors_stage.{h,cpp}
      • src/mongo/db/pipeline/expression_context.h — slot accessors
      • src/mongo/db/pipeline/change_stream_helpers.{h,cpp} — tryBuildErrorEvent
      • src/mongo/base/error_codes.yml — error codes 532, 533, and 534
      • src/mongo/db/pipeline/BUILD.bazel

      Tests

      Stage unit tests

      Verify that the stage:

      • Converts an eligible failure when an identity is recorded.
      • Fails closed and rethrows when no identity is available.
      • Materializes a pending resume gap on ChangeStreamHistoryLost.
      • Releases the stashed router event on ChangeStreamErrorEventBypass.
      • Rethrows non-convertible error codes.

      DocumentSource tests

      Verify serialization produces:

      • Explain: {{
        Unknown macro: {"$changeStream"}

        }}}

      • Wire: {"$_internalChangeStreamConvertErrors": {}}

      Also verify explain serialization for a sharded cluster; that path is currently broken and needs investigation.

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

              Created:
              Updated:
              Resolved: