Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-13208

The dropDups index option should be ignored if the index already exists

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.6.0-rc2
    • Component/s: Index Maintenance
    • Labels:
      None
    • Operating System:
      ALL

      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 })

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              eliot Eliot Horowitz (Inactive)
              Reporter:
              cailin.nelson Cailin Nelson
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: