[SERVER-78894] Allow update to work with a partial shard key and without the two phase protocol Created: 12/Jul/23  Updated: 15/Aug/23  Resolved: 15/Aug/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Wenqin Ye Assignee: Wenqin Ye
Resolution: Won't Fix Votes: 0
Labels: sharding-nyc-subteam3
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File image-2023-08-14-11-44-44-081.png    
Issue Links:
Related
is related to SERVER-44422 Allow findAndModify and delete one to... Closed
Assigned Teams:
Sharding NYC
Sprint: Sharding NYC 2023-07-24, Sharding NYC 2023-08-07, Sharding NYC 2023-08-21
Participants:

 Description   

At the moment, update commands do not work if you do not specify the full shard key in the following cases when the two phase protocol is disabled:

  • If the update command updates the shard key, then the full shard key has to be specified in the query
  • If the update command has `upsert == true` then the full shard key has to be specified in the query

This ticket should investigate and modify those cases so that they still work even if a partial shard key is provided (if it is possible). This code should also be backported to 5.0 and 6.0. 

The context for why this ticket is needed is that customers use resharding to quickly add a new shard, and that involves first refining the shard key to a new temporary shard key and then refining it back to the original. When the shard key is refined to a temporary one, that will cause some of the user's existing update queries to break as they expect the new full refined shard key. So this ticket will prevent user's existing queries from breaking when they refine their shard key temporarily for resharding. 



 Comments   
Comment by Wenqin Ye [ 15/Aug/23 ]

Yup as long as updateOne doesn't have upsert:True and does not update the shard key it will work if you provide a partial shard key in the query. 

Comment by Garaudy Etienne [ 15/Aug/23 ]

oh yeah that's right. Did you test that regular updateOne actually works? lol I forget

Comment by Wenqin Ye [ 14/Aug/23 ]

I forgot to close this ticket! It's not possible to fix updateOne upsert:True without doing some major code/functionality changes to updateOne (which may not be worth pursuing).

If you recall about a month ago, we had a discussion about this and you said that it is fine to keep the two limitations listed in this ticket (see the attached screenshot).

Comment by Garaudy Etienne [ 11/Aug/23 ]

does this mean we still need to fix updateOne upsert:True?

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