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

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

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Sharding
    • 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@mongodb.com Thomas Rueckstiess
            Reporter:
            lizhenyu2000 Zhenyu Li
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: