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

Throw WouldChangeOwningShard error on upsert if shard does not own new doc

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Fixed
    • Icon: Major - P3 Major - P3
    • 4.1.12
    • 4.1 Required
    • Sharding
    • None
    • Fully Compatible
    • Sharding 2019-05-20

    Description

      Once SERVER-39158 is done, replacement updates will target by query. We can then have a situation where a replacement upsert can target shard 1 using the query field, match 0 documents, and plan to insert the replacement document that actually belongs on shard 2.

      i.e. If shard 1 owns [x: -infinity, x: 0) and shard 2 owns [x:0, x: +infinity) and there does NOT exist a document {x: -10}, then a user does db.coll.update({x: -10}, {x: 10}), we will target shard 1 and not match any documents. We will then insert {x: 10}, but this should be inserted on shard 2 and not on shard 1. We should instead throw WouldChangeOwningShard error so that mongos can start a transaction if not already in one and insert the document on the correct shard.

      Attachments

        Activity

          People

            janna.golden@mongodb.com Janna Golden
            janna.golden@mongodb.com Janna Golden
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: