[SERVER-34971] Improve mongoS targeting of replacement-style updates for collections whose shard key includes _id Created: 13/May/18 Updated: 29/Oct/23 Resolved: 11/Jun/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying, Sharding |
| Affects Version/s: | None |
| Fix Version/s: | 4.1.1 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Bernard Gorman | Assignee: | Bernard Gorman |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||
| Backport Requested: |
v3.6
|
||||||||||||||||||||||||
| Sprint: | Query 2018-05-21, Query 2018-06-04, Query 2018-06-18 | ||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||||||||||
| Linked BF Score: | 3 | ||||||||||||||||||||||||
| Description |
|
Replacement-style updates on a sharded cluster are targeted by mongoS on the basis of the replacement document's shard key values rather than the query component, with some relaxed constraints for updates whose queries contain an exact match on _id. Consider a collection sharded on _id, or _id plus any number of additional fields. Then, replacement-style updates of the form shown below are legal, despite the fact that the replacement document does not contain the entire shard key:
This is because mongoD always automatically propagates the _id field of the existing document into the replacement document. The operation above will therefore succeed, assuming that the replacement document contains all other fields in the shard key and their values match those in the existing document. Similarly, it should also be legal to perform the above operation with upsert:true, since mongoD will extract the _id from the query component when generating the new document to upsert. However, there are a few shortcomings with the current targeting logic:
|
| Comments |
| Comment by Bernard Gorman [ 11/Jun/18 ] |
|
To summarise the changes introduced by this patch:
|
| Comment by Githook User [ 11/Jun/18 ] |
|
Author: {'username': 'gormanb', 'name': 'Bernard Gorman', 'email': 'bernard.gorman@gmail.com'}Message: |