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

Missing checks in collMod for shard key and unique index

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 6.1.1, 6.0.3, 6.2.0-rc0
    • Catalog, Sharding
    • None
    • Fully Compatible
    • v6.1, v6.0
    • Execution Team 2022-10-17

    Description

       

      The following does not fail:

      db.coll.createIndex({"a": 1}, {unique: false})
      sh.shardCollection( "test.coll", { b: 1 }, false, { collation: { locale: "simple" } } )
      db.runCommand({ collMod: "coll", index: { keyPattern: {"a": 1}, prepareUnique: true}})
      db.runCommand({ collMod: "coll", index: { keyPattern: {"a": 1}, unique: true}})
      

       

      Unlike trying to create the index on "a" with {unique: true} after the shardCollection which would give

      cannot create unique index over {a: 1.0} with shard key pattern {b: 1.0}

      I found this as part of the work on unlike topologies for cluster to cluster replication (Mongosync).

      Attachments

        Issue Links

          Activity

            People

              yuhong.zhang@mongodb.com Yuhong Zhang
              frederic.vitzikam@mongodb.com Frederic Vitzikam
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: