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

Create unique index on colleciton with hashed sharding key

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 2.4.6
    • Fix Version/s: 2.5.4
    • Component/s: Index Maintenance
    • Labels:
      None
    • Environment:
      Ubuntu 12.04.x LTS
      3.2.0-32-generic #51-Ubuntu SMP Wed Sep 26 21:33:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      create a collection with index

      {targetId : 1 ,timestamp: -1}, {unique : true}


      shard collection with with key

      { targetId: "hashed"}

      drop index

      {targetId : 1 ,timestamp: -1}


      try to recreate index

       {targetId : 1 ,timestamp: -1}, {unique : true}

      Show
      create a collection with index {targetId : 1 ,timestamp: -1}, {unique : true} shard collection with with key { targetId: "hashed"} drop index {targetId : 1 ,timestamp: -1} try to recreate index {targetId : 1 ,timestamp: -1}, {unique : true}

      Description

      We want to creat a compound index in a sharded collection with a hashed sharding key.

      The non hashed shard key is a prefix of the compound index.

      If we create the index before we shard the collection, mongodb does not complain about the index.

      {
      	"err" : "can't use unique indexes with sharding  ns:test.collection key: { targetId: 1.0, timestamp: -1.0 }",
      	"code" : 10205,
      	"n" : 0,
      	"ok" : 1
      }

        Attachments

          Activity

            People

            Assignee:
            scotthernandez Scott Hernandez
            Reporter:
            steffen Steffen
            Participants:
            Votes:
            3 Vote for this issue
            Watchers:
            9 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: