[SERVER-2863] Error creating index admin.system.users during mongorestore Created: 29/Mar/11  Updated: 12/Jul/16  Resolved: 29/Jul/11

Status: Closed
Project: Core Server
Component/s: Admin
Affects Version/s: 1.8.0
Fix Version/s: 1.9.2

Type: Bug Priority: Major - P3
Reporter: Ricardo Dias Assignee: Spencer Brody (Inactive)
Resolution: Done Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Operating System: ALL
Participants:

 Description   

We've had an error during mongorestore.
This was the error mensage:

Error creating index admin.system.users: 11000 E11000 duplicate key error index: admin.system.users.$id dup key: { : ObjectId('4d8352711a9f859ddd7de952') }

We'd used the --drop option on mongorestore, but it created the users again without removes them. Because that, it generated the error during index creation.

The command used for backup:
mongodump -h HOST -uUSER -pPWD -vvvvv -o backupDIR/

The command used for restore:
mongorestore -h HOST -uUSER -pPWD --drop -vvvvv backupDIR/

The complete restore log:
Tue Mar 29 16:09:52 creating new connection to:HOST
Tue Mar 29 16:09:52 BackgroundJob starting:
connected to: to:HOST
Tue Mar 29 16:09:52 drillDown: backupDIR/
Tue Mar 29 16:09:52 drillDown: backupDIR/admin
Tue Mar 29 16:09:52 drillDown: backupDIR/admin/system.users.bson
Tue Mar 29 16:09:52 backupDIR/admin/system.users.bson
Tue Mar 29 16:09:52 going into namespace [admin.system.users]
Tue Mar 29 16:09:52 dropping
Tue Mar 29 16:09:52 file size: 368
Tue Mar 29 16:09:52 4 objects found
Tue Mar 29 16:09:52 drillDown: backupDIR/admin/system.indexes.bson
Tue Mar 29 16:09:52 backupDIR/admin/system.indexes.bson
Tue Mar 29 16:09:52 going into namespace [admin.system.indexes]
Tue Mar 29 16:09:52 dropping
Tue Mar 29 16:09:52 file size: 158
Tue Mar 29 16:09:52 { name: "id", ns: "admin.system.users", key:

{ _id: 1 }

, v: 0 }
Error creating index admin.system.users: 11000 E11000 duplicate key error index: admin.system.users.$id dup key: { : ObjectId('4d8352711a9f859ddd7de952') }
To resume index restoration, run mongorestore on file backupDIR/admin/system.indexes.bson manually.
Aborted



 Comments   
Comment by Spencer Brody (Inactive) [ 29/Jul/11 ]

The problem was that we have checks that prevent dropping system collections, so the system.users collection doesn't get dropped, then you get duplicate key values when trying to add back in the same users.

The fix special cases the system.users collection in mongorestore and manually adds/removes entries instead of relying on the dump command to clear the collection first.

Comment by auto [ 29/Jul/11 ]

Author:

{u'login': u'stbrody', u'name': u'Spencer T Brody', u'email': u'spencer@10gen.com'}

Message: Make mongorestore be able to properly restore system.users with --drop. SERVER-2863
Branch: master
https://github.com/mongodb/mongo/commit/3c55e8ccbaa9acff4cf9594771f67e935b18d9a4

Comment by Richard Kreuter (Inactive) [ 30/Mar/11 ]

Have a reproduction case. Probably fixing this tomorrow. Thanks for the report.

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