Upsert and Shard is tightly coupled, and there is no clear documentation on that

XMLWordPrintableJSON

    • Type: Question
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Sharding
    • None
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      To perform "upsert" operation on a sharded MongoDB cluster, the query MUST exactly match the shard key.

      For example:

      update( {a:1, b:2}, { $setOnInsert { c : 3, d : 4}}, { upsert: true})
      

      The above update does not work if the shard is key is for example

      {a: 1, _id: 1}. 
      

      Is this the designed behavior? If so, why cannot I not find the detailed example or warning for this? Since the shard kay cannot be modified, this is causing huge problems. It just completely broke our migration from a stand-alone server to the sharded cluster.

            Assignee:
            Thomas Rueckstiess (Inactive)
            Reporter:
            Zhenyu Li
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: