Change stream v2 resume after rename targets db primary shard

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Catalog and Routing
    • Fully Compatible
    • ALL
    • QE 2026-05-11, QE 2026-04-27, QE 2026-03-30, QE 2026-03-16, QE 2026-04-13
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      https://github.com/10gen/mongo/pull/48779/

      Test setup. 
      Cluster: 3 shards, 1 mongos, 1 config server, balancer off.Setup:

      1. Pin DB primary to shard0 (enableSharding with primaryShard: shard0)
      1. Create unsplittable collection on shard1 (non-primary) — data lives on shard1
      1. Open a collection-level change stream from a cluster time before the commands

      Sequence:

      1. CreateDatabase → pins primary to shard0 (no events)
      1. CreateUnsplittableCollection on shard1 → emits create
      1. RenameToNonExistent → emits rename, invalidate
      1. InsertDoc (recreates collection implicitly) → emits create, insert, insert

      Expected events: [create, rename, invalidate, create, insert, insert]Bug: After the invalidate, v2 resumes using historical placement.

      The old namespace's last placement record has shards: [] (renamed away). The pipeline discards it and falls back to DB-level placement → targets shard0 (DB primary).

      But the invalidate's resume token points to shard1 (where the data actually was). The resumed cursor opens on the wrong shard and never sees the post-rename create and insert events.

      Result: v2 returns only [create, rename, invalidate] — stuck at 3 events instead of 6.

            Assignee:
            Paolo Polato
            Reporter:
            Nicola Cabiddu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: