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

    XMLWordPrintable

    Details

    • Type: Question
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Sharding
    • Labels:
      None

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: