[SERVER-11925] movePrimary command clones system.users collection Created: 02/Dec/13  Updated: 10/Dec/14  Resolved: 21/May/14

Status: Closed
Project: Core Server
Component/s: Security, Sharding
Affects Version/s: 2.4.6
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Sherry Ger Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Operating System: ALL
Steps To Reproduce:
  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()
Participants:

 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.



 Comments   
Comment by Andreas Nilsson [ 13/Mar/14 ]

In 2.4 and 2.6 clusters with legacy system.users collections there is a straightforward workaround of removing the users from one of the shards.

Generated at Thu Feb 08 03:27:07 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.