-
Type: Bug
-
Resolution: Done
-
Priority: Critical - P2
-
Affects Version/s: None
-
Component/s: Index Maintenance
-
None
-
ALL
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 })
- related to
-
SERVER-12980 Background fields are not ignored when comparing index spec equality
- Closed