CreateIndexes command fails when building duplicate entries.

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 2.7.5
    • Component/s: Index Maintenance
    • None
    • Minor Change
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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
        }
      

            Assignee:
            Mathias Stearn
            Reporter:
            Mathias Stearn
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: