[SERVER-70592] Have clusterQueryWithoutShardKey apply the sort order if findAndModify supplies one Created: 14/Oct/22 Updated: 29/Oct/23 Resolved: 20/Mar/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.0.0-rc0 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Jason Zhang | Assignee: | Jason Zhang |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Sprint: | Sharding 2022-12-12, Sharding NYC 2023-01-09, Sharding NYC 2023-02-20, Sharding NYC 2023-03-06, Sharding NYC 2023-03-20, Sharding NYC 2023-04-03 |
| Participants: |
| Comments |
| Comment by Githook User [ 20/Mar/23 ] |
|
Author: {'name': 'Jason Zhang', 'email': 'jason.zhang@mongodb.com', 'username': 'jz1242'}Message: |
| Comment by Sanika Phanse (Inactive) [ 05/Jan/23 ] |
|
Chatted with Nick on Query, came up with an approach:
Alternative approach:
|
| Comment by Sanika Phanse (Inactive) [ 04/Jan/23 ] |
|
Investigated approach #2 today, the ARM seems pretty deeply tied with the implementation of cluster_find & cluster_aggregation. Doing a bit more final investigation to see if there's a way to isolate the ARM sorting layer, but I'll likely pursue option #1. There might be advantages to setting returning the $sortKey value from each shard along with the target document as it would allow doing a direct binary comparison between documents. |
| Comment by Sanika Phanse (Inactive) [ 04/Jan/23 ] |
|
Currently, AsyncResultsMerger gathers and sorts results from open cursors in a multi-shard find command or aggregation. In the current implementation of _clusterQueryWithoutShardKey, we collect a set of matching documents from an ARS and select one as the target doc. Two options come to mind here: |
| Comment by Sanika Phanse (Inactive) [ 03/Jan/23 ] |
|
{sort: true}
can only be set for findAndModify commands (update/delete do not support this field). If a collation is spec'd in this findAndModify command, use it during the final sorting as well. |
| Comment by Sanika Phanse (Inactive) [ 03/Jan/23 ] |
|
High level approach: In _clusterQueryWithoutShardKey,
|