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

Background fields are not ignored when comparing index spec equality

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 2.6.0-rc1
    • Index Maintenance
    • ALL
    • Hide

      var coll = db.newColl;
      coll.drop();
       
      coll.ensureIndex({foo: 1}, {background: false});
      coll.ensureIndex({foo: 1});

      Show
      var coll = db.newColl; coll.drop();   coll.ensureIndex({foo: 1}, {background: false}); coll.ensureIndex({foo: 1});

    Description

      If you have two index specs that are the same except for the presence of a 'background' field, ensureIndexes will no longer treat them as identical specs. This bug is a result of the changes from SERVER-10879.

      Error with master:

      > var coll = db.newColl;
      > coll.drop();
      true
      > 
      > coll.ensureIndex({foo: 1}, {background: false});
      WriteResult({ "nInserted" : 1 })
      > coll.ensureIndex({foo: 1});
      WriteResult({
      	"nInserted" : 0,
      	"writeError" : {
      		"code" : 67,
      		"errmsg" : "Index with name: foo_1 already exists with different options"
      	}
      })

      No error with 2.4.9:

      > var coll = db.newColl;
      > coll.drop();
      true
      > 
      > coll.ensureIndex({foo: 1}, {background: false});
      > coll.ensureIndex({foo: 1});
      > 
       


      Version: 914a26f51ff7ffeb28922273925318da6a6eba71

      Attachments

        Issue Links

          Activity

            People

              rassi J Rassi
              kamran.khan Kamran K.
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: