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

Background fields are not ignored when comparing index spec equality

    • 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});

      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

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

              Created:
              Updated:
              Resolved: