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

Missing checks in collMod for shard key and unique index

    • Fully Compatible
    • v6.1, v6.0
    • Execution Team 2022-10-17

       

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

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

              Created:
              Updated:
              Resolved: