jstest + design for cross-DB renameCollection staging-collection events leaking into change streams (SERVER-107688)

    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      jstest + design doc for SERVER-107688: database-level change-stream readers see the temporary collection's insert events from the data-cloning phase of a cross-DB rename. Confuses external consumers (mongosync, CDC pipelines).

      Files

      • jstests/change_streams/cross_db_rename_no_staging_events.js (162 lines) — 4 scenarios: {DB-scoped, cluster-scoped}

        ×

        {dropTarget:false, true}

        . Helper eventIsForStagingNamespace regex-matches the tmp[a-zA-Z0-9]{5}.renameCollection namespace (pattern from ddl_rename_cross_db.js). Cluster path uses adminDb.aggregate([{$changeStream: {allChangesForCluster: true\}\}]) and drains until the user-facing rename. DB path asserts the first drained event is the public rename, never a staging insert/createIndexes/create.

      • src/mongo/db/pipeline/CROSSDB_RENAME_FIX.md (90 lines)

      Key finding

      Parser is already correct: change_stream_filter_helpers.cpp:buildNotFromMigrateFilter (lines 143–158) drops fromMigrate:true ops. *Fix is upstream in src/mongo/db/catalog/rename_collection.cpp::renameBetweenDBs*: set fromMigrate=true on the staging create + createIndexes + per-document insert calls. Diff sketch threads fromMigrate=true through collection_internal::insertDocuments + IndexBuildsCoordinator::createIndexes + CollectionOptions.fromMigrate.

      ddl_rename_cross_db.js lines 170–179 currently assert the leak as status quo and will need inverting once the catalog fix lands.

      Verify

      • node --input-type=module --check on the jstest: clean.

            Assignee:
            Unassigned
            Reporter:
            Mehar Grewal
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: