[SERVER-17628] Unique Index Creation Fails Despite `dropDups` Created: 17/Mar/15  Updated: 17/Mar/15  Resolved: 17/Mar/15

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: 3.0.0, 3.0.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Christian Bankester Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-17599 dropDups ignored on index creation Closed
Operating System: ALL
Steps To Reproduce:
  1. Open MongoDB Shell
  2. Switch to database `mydb`
  3. Insert `{x: 1}` into collection `testData`
  4. Create index on key `x` of collection `testData`, specifying option `{unique: true, dropDups: true}`
Participants:

 Description   

When attempting to create a unique index on a key with duplicates (i.e. using the `dropDups: true` option), the index creation fails with a duplicate key error.

MongoDB shell version: 3.0.1

connecting to: test
> use mydb
switched to db mydb
> db.testData.insert({x: 1})
WriteResult({ "nInserted" : 1 })
> db.testData.insert({x: 1})
WriteResult({ "nInserted" : 1 })
> db.testData.createIndex({x: 1}, {unique: true, dropDups: true})
{
	"createdCollectionAutomatically" : false,
	"numIndexesBefore" : 1,
	"errmsg" : "exception: E11000 duplicate key error index: mydb.testData.$x_1 dup key: { : 1.0 }",
	"code" : 11000,
	"ok" : 0
}



 Comments   
Comment by Christian Bankester [ 17/Mar/15 ]

Thanks, ramon.fernandez. https://jira.mongodb.org/browse/DOCS-5012 is a highly relevant issue to anyone wondering.

Sorry for the bother!

Comment by Ramon Fernandez Marina [ 17/Mar/15 ]

cmbankester, the dropDups option was removed from MongoDB 3.0. Please see SERVER-17599 for more information.

Regards,
Ramón.

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