ExportXMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Minor - P4
    • 9.1.0-rc0, 9.1.0-rc1025
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • Fully Compatible
    • QI 2025-02-17
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Background

      A collection-level change stream is invalidated when its watched collection is renamed (A→B):
      the stream delivers a rename event followed by an invalidate. To keep consuming, the
      client must reopen a stream — the natural recovery is to open it over the RENAMED collection B,
      resuming from the invalidate token. That recovery path is untested today: existing coverage only
      resumes on the original namespace.

      Behavior (pinned by the new test)

      • resumeAfter with an invalidate token is refused with InvalidResumeToken — the only
        gate is DocumentSourceChangeStream::assertIsLegalSpecification
        (src/mongo/db/pipeline/document_source_change_stream.cpp), refusing exactly
        resumeAfter && fromInvalidate.
      • startAfter with the invalidate token reopens the stream: the invalidate token is built
        from the invalidating event's token and RETAINS the rename event's collection UUID
        (change_stream_check_invalidate_stage.cpp:112-114), and the rename preserves that UUID while
        changing the namespace — so resuming on B satisfies the single-collection UUID requirement
        (document_source_change_stream.cpp:749-758). The oplog scan resumes past the invalidate
        point — delivering events that landed on B after the rename.

      Scope of Work

      1. New coverage (primary)

      • Watch A → rename A→B → observe rename + invalidate → capture the invalidate token
      • Insert into B, reopen with startAfter: <invalidate token> on B
      • Assert the stream delivers the post-rename insert on the new namespace

      2. Refactor (secondary, boy-scout)

      • Rewrite jstests/change_streams/metadata_notifications.js as a mochalite suite: 19
        self-contained it() tests with per-test fixtures, replacing the linear script's cross-block
        state threading
      • Rename tests (including the new recovery test) run on SHARDED collections too — verified: a
        sharded rename delivers exactly [rename, invalidate] to a collection stream through mongos.
        Only the $out test keeps an unsharded guard ($out to a sharded collection is rejected:
        NamespaceCannotBeSharded); the fixture check is computed inside each test per the
        update_lookup_before_ddl.js convention
      • No server changes

      Acceptance Criteria

      • All 19 tests pass in the change_streams resmoke suite (verified locally)
      • Sharded passthroughs and burn-ins validated by the required Evergreen patch
      • Formatting per repo standard (bazel run format)

      Related

      • SERVER-41196 — startAfter over an invalidate token opens a stream but yields no events

            Assignee:
            Denis Grebennicov
            Reporter:
            Denis Grebennicov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: