[SERVER-13208] The dropDups index option should be ignored if the index already exists Created: 14/Mar/14  Updated: 11/Jul/16  Resolved: 17/Mar/14

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: 2.6.0-rc2

Type: Bug Priority: Critical - P2
Reporter: Cailin Nelson Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-12980 Background fields are not ignored whe... Closed
Operating System: ALL
Participants:

 Description   

If you create an index with dropDups:true then you cannot call ensureIndex again without the dropDups:true. The background:T/F option is already ignored .

Both dropDups and background only influence MongoDB behavior when creating the index. Therefore, it seems like neither of them should be considered part of the index definition wrt if the index already exists, and should not be used to compare for an existing index.

dropDups behavior

backup_test:PRIMARY> db.users.ensureIndex({username:1},{name:'idxUsername',unique:true,dropDups:true})
WriteResult({ "nInserted" : 1 })
backup_test:PRIMARY> db.users.ensureIndex({username:1},{name:'idxUsername',unique:true})
WriteResult({
	"nInserted" : 0,
	"writeError" : {
		"code" : 67,
		"errmsg" : "Index with name: idxUsername already exists with different options"
	}
})

background behavior

backup_test:PRIMARY> db.users.ensureIndex({username:1},{unique:true, name: 'idxUsername', background:true})
WriteResult({ "nInserted" : 1 })
backup_test:PRIMARY> db.users.ensureIndex({username:1},{unique:true, name: 'idxUsername'})
WriteResult({ "nInserted" : 0 })



 Comments   
Comment by Githook User [ 17/Mar/14 ]

Author:

{u'username': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: SERVER-13208: drop dups should be allowed to be different
Branch: v2.6
https://github.com/mongodb/mongo/commit/c78bdafae31dd77288fbe7366eb522f7cc8ab427

Comment by Githook User [ 17/Mar/14 ]

Author:

{u'username': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: SERVER-13208: drop dups should be allowed to be different
Branch: master
https://github.com/mongodb/mongo/commit/a173f84cb956fadc1169f32709679260bd517585

Comment by Githook User [ 17/Mar/14 ]

Author:

{u'username': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: SERVER-13208: dropDups should be ignored for index comparison
Branch: v2.6
https://github.com/mongodb/mongo/commit/8d3be24f178c512d68d7dfc90cf494455a002c55

Comment by Githook User [ 17/Mar/14 ]

Author:

{u'username': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: SERVER-13208: dropDups should be ignored for index comparison
Branch: master
https://github.com/mongodb/mongo/commit/e7b7ed4cfdd110c98dac1d7ffa08be6bd9e25cfe

Comment by Eric Milkie [ 14/Mar/14 ]

This shouldn't be too hard to fix since the duplicate dropping is replicated as individual deletes, independent of the index build op in the oplog, so it's not necessary to propagate the dropDups parameter as part of the index spec.

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