WARNING: the collection 'dummy-collection-name' lacks a unique index on _id. This index is needed for replication to function properly

658 views
Skip to first unread message

praveen akinapally

unread,
Jul 8, 2015, 8:47:05 PM7/8/15
to mongod...@googlegroups.com
Hi Guys,

When i login to mongo shell I am getting.:

WARNING: the collection 'dummy-collection-name' lacks a unique index on _id. This index is needed for replication to function properly
To fix this, you need to create a unique index on _id. See http://dochub.mongodb.org/core/build-replica-set-indexes

Note: This warning shows up only on login to mongo shell on few shards not on all shards 

The _id is a Object Id which is generated automatically on insert so it should be unique and no way it can be duplicate. Also the insert would have failed right away if there is duplicate id. But according to error the collection currently has duplicate ids. How is this possible ?

Any help would be highly appreciated.

Thanks and Regards,
Praveen


Eric Milkie

unread,
Jul 9, 2015, 5:18:25 PM7/9/15
to mongod...@googlegroups.com
The error does not say the collection currently has duplicate ids.

The error says that the collection doesn't have a unique index on the _id field.  The unique index is the only way to guarantee that all _id values are unique.  For each document update operation, replication uses the _id index to find each corresponding document on secondary nodes.  Without the index, replication performance will suffer immensely and there will be no protection against data corruption if a user were to mistakenly insert documents with duplicate _id values.
Reply all
Reply to author
Forward
0 new messages