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

dropIndex not working if a name was specified during the ensureIndex

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.2.2, 2.3.0
    • Affects Version/s: 1.6.0
    • Component/s: Admin, Usability
    • Labels:
      None
    • Environment:
      All
    • Fully Compatible
    • ALL

      Problem:
      If an index is created with a name, then dropIndex will fail to drop the index. However, runCommand(

      {dropIndexes...}) succeeds.

      Reproduce:
      Do the following
      > db.journeys.save( {type :1, tm_uuid:2} )                            
      > db.journeys.ensureIndex({type:1, tm_uuid:1}, {name:"Type TM-UUID"}); 
      
      > db.journeys.getIndexes() 
      [
      	{
      		"name" : "_id_",
      		"ns" : "test.journeys",
      		"key" : {
      			"_id" : 1
      		}
      	},
      	{
      		"_id" : ObjectId("4cab0f09f29d24000f38d92f"),
      		"ns" : "test.journeys",
      		"key" : {
      			"type" : 1,
      			"tm_uuid" : 1
      		},
      		"name" : "Type TM-UUID"
      	}
      ]
      
      
      > db.journeys.dropIndex({name:"Type TM-UUID"});                      
      { "errmsg" : "index not found", "ok" : 0 }
      
      
      > db.runCommand({dropIndexes:'journeys', index : {type:1,tm_uuid:1}})
      { "nIndexesWas" : 2, "ok" : 1 }
      
      
      > db.journeys.getIndexes()                                           
      [
      	{
      		"name" : "_id_",
      		"ns" : "test.journeys",
      		"key" : {
      			"_id" : 1
      		}
      	}
      ]
      

      Workaround:
      Use db.runCommand({dropIndexes...}

      ) to drop a index with a name.

      Business Case:
      User Expereince

            Assignee:
            tad Tad Marshall
            Reporter:
            alvin Alvin Richards (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: