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

ensureIndex() fails to create unique index if non-unique index already exists

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.8.0-rc1
    • Component/s: Index Maintenance
    • None
    • Environment:
      Windows 7, single instance, no shards
    • ALL

      db.foo.ensureIndex(

      {a : 1}

      );
      db.foo.save(

      {key:1, a:1}

      );
      db.foo.save(

      {key:2, a:2}

      );

      db.foo.ensureIndex(

      {a : 1}

      ,

      {name:'uniquea', unique:true}

      );

      db.foo.getIndexes() shows that 'uniquea' has not been created. While we should be checking to avoid creating exact duplicate indexes, my attempt to create a new unique index should succeed, because there isn't already a unique one. I might be doing this in preparation for replacing the (non-unique) 'a_1' index with 'uniquea'.

            Assignee:
            Unassigned Unassigned
            Reporter:
            dan@mongodb.com Daniel Pasette (Inactive)
            Votes:
            4 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: