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

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 4.1.12
    • Affects Version/s: 4.1 Required
    • Component/s: Sharding
    • None
    • Fully Compatible
    • Sharding 2019-05-20
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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.

            Assignee:
            Janna Golden
            Reporter:
            Janna Golden
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: