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

CreateIndexes command fails when building duplicate entries.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.7.5
    • Index Maintenance
    • None
    • Minor Change
    • ALL

    Description

      In 2.6 the first index would succeed and the later builds would be skipped since the index now exists. In master this fails because the code to skip existing indexes happens before we build any indexes, so we attempt to build both indexes and fail:

      db = db.getSiblingDB("createIndexes");
      db.dropDatabase();
      db.test.runCommand( "createIndexes", { indexes : [ { name : "x_1", key : { "x" : 1 }, ns: "createIndexes.test" }, 
                                                         { name : "x_1", key : { "x" : 1 }, ns: "createIndexes.test" } ] } );
       
      // 2.6.3 result:
        {
        	"createdCollectionAutomatically" : true,
        	"numIndexesBefore" : 1,
        	"note" : "index already exists",
        	"numIndexesAfter" : 2,
        	"ok" : 1
        }
      // 2.7 Nightly Result
        {
        	"createdCollectionAutomatically" : true,
        	"numIndexesBefore" : 1,
        	"errmsg" : "exception: x_1",
        	"code" : 68, // IndexAlreadyExists
        	"ok" : 0
        }

      Attachments

        Activity

          People

            mathias@mongodb.com Mathias Stearn
            mathias@mongodb.com Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: