[SERVER-75927] Shards see different values for 'let' parameter when using $rand Created: 10/Apr/23 Updated: 29/Oct/23 Resolved: 10/Oct/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.2.0-rc0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | David Storch | Assignee: | David Percy |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | query-director-triage, query-product-scope-1, query-product-urgency-1, query-product-value-2 | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
|||||||||||||||||||||||||||||||
| Assigned Teams: |
Query Optimization
|
|||||||||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | |||||||||||||||||||||||||||||||
| Operating System: | ALL | |||||||||||||||||||||||||||||||
| Steps To Reproduce: | I wrote the following script to demonstrate the issue:
I'm running it locally with a resmoke.py invocation like this:
|
|||||||||||||||||||||||||||||||
| Sprint: | QO 2023-06-26, QO 2023-07-10, QO 2023-07-24, QO 2023-08-07, QO 2023-08-21, QO 2023-09-04, QO 2023-09-18, QO 2023-10-02, QO 2023-10-16 | |||||||||||||||||||||||||||||||
| Participants: | ||||||||||||||||||||||||||||||||
| Description |
|
In
The intended semantics is that the $rand expression is evaluated just once up front and the result is treated as a constant for the remainder of the execution of the query. In sharded contexts, mongos should generate the random number and pass it to the shards so that all shards see the same random number. This is not working as expected. Glancing at the code, it looks like we are sending the full $rand expression to each shard. As a result, each shard generates its own random number. My script in "steps to reproduce" has a full example of the problem. |
| Comments |
| Comment by Githook User [ 10/Oct/23 ] |
|
Author: {'name': 'David Percy', 'email': 'david.percy@mongodb.com', 'username': 'dpercy'}Message: Command-level let bindings are evaluated once for the whole command. For Previously this was only working correctly for sharded aggregate queries: This commit also includes test cases to demonstrate the same bug in |