[SERVER-41002] Throw WouldChangeOwningShard error on upsert if shard does not own new doc Created: 03/May/19  Updated: 29/Oct/23  Resolved: 16/May/19

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 4.1 Required
Fix Version/s: 4.1.12

Type: Task Priority: Major - P3
Reporter: Janna Golden Assignee: Janna Golden
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Sprint: Sharding 2019-05-20
Participants:

 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.



 Comments   
Comment by Githook User [ 16/May/19 ]

Author:

{'email': 'golden.janna@gmail.com', 'name': 'jannaerin', 'username': 'jannaerin'}

Message: SERVER-41002 Throw WouldChangeOwningShardError on upsert if shard does not own new doc
Branch: master
https://github.com/mongodb/mongo/commit/ee02f40bd8f3f6bfd9d2c8cbfeed59451c034166

Generated at Thu Feb 08 04:56:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.