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

movePrimary command clones system.users collection

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.4.6
    • Security, Sharding
    • None
    • ALL
    • Hide
      1. Create 2 replica sets
      2. Start a 2 shard cluster with the replica sets from above
      3. Create CS9719 database on each replica set
      4. Add user "test_users" to the database "CS9719" on each replica set
      5. Enable sharding on the database "CS9719"
      6. Shard a collection "MyCollection"
      7. Import data into "MyCollection"
      8. Run command

        db.runCommand({removeShard:"shard-b"})

      9. After verifying no chunk exists on shard-b, run the command movePrimary

        db.runCommand({ movePrimary : "CS9719", to : "shard-a" })

      10. Observe the errors in the mongos log and the draining state from sh.status()
      Show
      Create 2 replica sets Start a 2 shard cluster with the replica sets from above Create CS9719 database on each replica set Add user "test_users" to the database "CS9719" on each replica set Enable sharding on the database "CS9719" Shard a collection "MyCollection" Import data into "MyCollection" Run command db.runCommand({removeShard:"shard-b"}) After verifying no chunk exists on shard-b, run the command movePrimary db.runCommand({ movePrimary : "CS9719", to : "shard-a" }) Observe the errors in the mongos log and the draining state from sh.status()

    Description

      The movePrimary command clones all un-sharded collections from the source shard to the target shard. If the system.users collection exists on both shards and they contain the same user, the movePrimary will fail with the following error in the log.

      Mon Dec  2 12:19:35.204 [conn1] clone failed{ errmsg: "exception: E11000 duplicate key error index: CS9719.system.users.$user_1_userSource_1  dup key: { : "test_user", : null }", code: 11000, ok: 0.0 }

      Also, when the movePrimary command failed, the shard is being left in the draining state

      {  "_id" : "shard-b",  "draining" : true,  "host" : "shard-b/localhost:47017,localhost:47018" }

      Because system.users is a system collection, it cannot be removed from the database.

      Attachments

        Activity

          People

            Unassigned Unassigned
            sherry.ger@10gen.com Sherry Ger
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: