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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical - P2
    • Resolution: Done
    • None
    • 2.6.0-rc2
    • Index Maintenance
    • None
    • 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

              eliot Eliot Horowitz (Inactive)
              cailin.nelson@mongodb.com Cailin Nelson
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: