[SERVER-75356] explain command for a find with $expr and let parameters fails if the collection is sharded Created: 27/Mar/23 Updated: 29/Oct/23 Resolved: 13/Apr/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.0.0-rc0, 7.1.0-rc0, 6.0.6 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Cheahuychou Mao | Assignee: | David Storch |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||
| Assigned Teams: |
Query Execution
|
||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||
| Backport Requested: |
v7.0, v6.3, v6.0, v5.0
|
||||||||||||||||||||
| Sprint: | QE 2023-04-17 | ||||||||||||||||||||
| Participants: | |||||||||||||||||||||
| Description |
|
For an unsharded collection, the following explain command runs successfully.
However, for a sharded collection, it fails with the following error:
The behavior is the same on the 6.0 branch. |
| Comments |
| Comment by Githook User [ 18/Apr/23 ] |
|
Author: {'name': 'David Storch', 'email': 'david.storch@mongodb.com', 'username': 'dstorch'}Message: (cherry picked from commit 7ed14a4b2c043c639d1c6aa4d22f80f30ca44d97) |
| Comment by Githook User [ 17/Apr/23 ] |
|
Author: {'name': 'David Storch', 'email': 'david.storch@mongodb.com', 'username': 'dstorch'}Message: (cherry picked from commit 33e6eec5978a20a4b227c36f26b0ae909e8e6728) |
| Comment by Githook User [ 13/Apr/23 ] |
|
Author: {'name': 'David Storch', 'email': 'david.storch@mongodb.com', 'username': 'dstorch'}Message: |
| Comment by David Storch [ 06/Apr/23 ] |
|
I spent a little bit of time debugging this. The spurious error gets produced on mongos before the operation is ever forwarded to the shards. It happens as we are parsing the query with an incompletely initialized ExpressionContext for the purpose of shard targeting. Specifically, the error happens while we are creating a CanonicalQuery in this code path: It's a similar problem to |