V2 change stream readers may miss events when the resume point matches the commit of a chunk migration

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Catalog and Routing
    • CAR Team 2026-07-20
    • 🟥 DDL
    • None
    • None
    • None
    • None
    • None
    • None

      Problem

      V2 change streams (featureFlagChangeStreamPreciseShardTargeting) can observe migrateLastChunkFromShard on a live stream, but resumeAfter that token fails:

      ChangeStreamFatalError: cannot resume stream; the resume token was not found.
      

      Repro: migrate_last_chunk_from_shard_event.js (excluded from CI — change_streams.yml).

      Root cause

      Chunk migration change-stream events are written to the donor shard oplog by buildMoveChunkOplogEntries. The resume token therefore points at an oplog entry on the donor.

      On resume, ChangeStreamShardTargeterBase::initialize picks which shard cursors to open from placement history at the token's clusterTime. After migration, that placement is usually the recipient only — the donor is not opened.

      ChangeStreamEnsureResumeTokenPresentStage never sees the token on an open cursor and fails with ChangeStreamFatalError: cannot resume stream; the resume token was not found.

            Assignee:
            Paolo Polato
            Reporter:
            Paolo Polato
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: