Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-87814

MovePrimary creates collection on destination but doesn't copy documents / indexes

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Critical - P2 Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Catalog and Routing
    • ALL
    • Hide

      Create a two shard cluster. Assuming database "test" lives on "shard-rs1" initially, connect to mongos, and then:

      // Create an unsharded collection
      mongos> db.mycoll.insert({a: 1})
      
      // Move primary from the original home "shard-rs1" to "shard-rs0"
      mongos> db.adminCommand({movePrimary: 'test', to: 'shard-rs0'})
      

      Now if you connect to shard-rs1 directly, you'll see that "test.mycoll" still exists on it.

      Show
      Create a two shard cluster. Assuming database "test" lives on "shard-rs1" initially, connect to mongos, and then: // Create an unsharded collection mongos> db.mycoll.insert({a: 1}) // Move primary from the original home "shard-rs1" to "shard-rs0" mongos> db.adminCommand({movePrimary: 'test' , to: 'shard-rs0' }) Now if you connect to shard-rs1 directly, you'll see that "test.mycoll" still exists on it.
    • CAR Team 2024-03-18
    • 129

      When the feature flag gTrackUnshardedCollectionsUponCreation is enabled, on movePrimary the call to get unsplittable collections catalogClient->getUnsplittableCollectionNamespacesForDb() returns all unsharded collections.

      This is added to the list of "tracked collections".

      However later on when we copy the DB over we create all the collections, but if the collection is a tracked collection we neither copy the indexes over nor copy the contents of the collection over either.

      Seen on base commit 64dca7eaed26da5ee7547e1d62be599a87678327

            Assignee:
            allison.easton@mongodb.com Allison Easton
            Reporter:
            vishnu.kaushik@mongodb.com Vishnu Kaushik
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: