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

Create unique index on colleciton with hashed sharding key

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 2.4.6
    • 2.5.4
    • Index Maintenance
    • None
    • 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
    • ALL
    • 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

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

            Dates

              Created:
              Updated:
              Resolved: