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

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

    XMLWordPrintable

    Details

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

      Description

      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'.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              pasette Daniel Pasette
              Participants:
              Votes:
              4 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: