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

movePrimary command clones system.users collection

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.4.6
    • Component/s: Security, Sharding
    • Labels:
      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()

      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.

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

              Created:
              Updated:
              Resolved: