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

ensureIndex does not enforce constraints until collection exists

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Gone away
    • Affects Version/s: 2.3.2, 2.4.0-rc0
    • Fix Version/s: None
    • Component/s: Index Maintenance
    • Labels:
      None
    • Environment:
      OS X
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      > use qa
      switched to db qa
      > db.test.ensureIndex({ts:"hashed"}, {hashVersion:1})
      > db.test.insert({ts:ISODate()})
      Only HashVersion 0 has been defined
      > db.dropDatabase()
      { "dropped" : "qa", "ok" : 1 }

      Expected behavior:

      > use qa
      switched to db qa
      > db.test.insert({ts:ISODate()})
      > db.test.ensureIndex({ts:"hashed"}, {hashVersion:1})
      {
      	"err" : "Only HashVersion 0 has been defined",
      	"code" : 16245,
      	"n" : 0,
      	"connectionId" : 5,
      	"ok" : 1
      }

      Show
      > use qa switched to db qa > db.test.ensureIndex({ts:"hashed"}, {hashVersion:1}) > db.test.insert({ts:ISODate()}) Only HashVersion 0 has been defined > db.dropDatabase() { "dropped" : "qa", "ok" : 1 } Expected behavior: > use qa switched to db qa > db.test.insert({ts:ISODate()}) > db.test.ensureIndex({ts:"hashed"}, {hashVersion:1}) { "err" : "Only HashVersion 0 has been defined", "code" : 16245, "n" : 0, "connectionId" : 5, "ok" : 1 }

      Description

      ensureIndex does not enforce constraints such as hashVersion can only be 0 until data exists in collection.

        Attachments

          Activity

            People

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            epc Ed Costello
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: