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

collection.ensureIndex should ignore unsupported options

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Duplicate
    • None
    • None
    • Index Maintenance
    • None

    Description

      Running MongoDB 2.6.8, I get:

      > db.notification.getIndexes()[1]
      {
      	"v" : 1,
      	"key" : {
      		"_cls" : 1,
      		"membership" : 1
      	},
      	"ns" : "closeio.notification",
      	"name" : "_cls_1_membership_1",
      	"background" : false,
      	"dropDups" : false
      }
      > db.notification.ensureIndex({ _cls: 1, membership: 1 })
      { "numIndexesBefore" : 14, "note" : "all indexes already exist", "ok" : 1 }
      > db.notification.ensureIndex({ _cls: 1, membership: 1 }, { background: true })
      { "numIndexesBefore" : 14, "note" : "all indexes already exist", "ok" : 1 }
      > db.notification.ensureIndex({ _cls: 1, membership: 1 }, { whatever: true })
      {
      	"ok" : 0,
      	"errmsg" : "Index with name: _cls_1_membership_1 already exists with different options",
      	"code" : 85
      }
      > db.notification.ensureIndex({ _cls: 1, membership: 1, whatever:1 }, { whatever: true })
      {
      	"createdCollectionAutomatically" : false,
      	"numIndexesBefore" : 14,
      	"numIndexesAfter" : 15,
      	"ok" : 1
      }
      > db.notification.getIndexes()[14]
      {
      	"v" : 1,
      	"key" : {
      		"_cls" : 1,
      		"membership" : 1,
      		"whatever" : 1
      	},
      	"name" : "_cls_1_membership_1_whatever_1",
      	"ns" : "closeio.notification",
      	"whatever" : true
      }

      1. Calling ensureIndex with an unsupported option shouldn't consider the spec different from the existing one (i.e. the error shouldn't occur).
      2. Options that aren't supported shouldn't be stored on the index spec.

      Do you agree?

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              wojcikstefan Stefan Wójcik
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: