[SERVER-74954] Incorrect result when contained $or rewrites $elemMatch extra condition Created: 16/Mar/23 Updated: 29/Oct/23 Resolved: 28/Jun/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 4.4.19, 6.0.5, 6.3.0-rc1 |
| Fix Version/s: | 7.1.0-rc0, 5.0.20, 6.0.9, 7.0.2 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Asya Kamsky | Assignee: | Svilen Mihaylov (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | query-director-triage | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Assigned Teams: |
Query Optimization
|
||||||||||||||||
| Backwards Compatibility: | Minor Change | ||||||||||||||||
| Operating System: | ALL | ||||||||||||||||
| Backport Requested: |
v7.0, v6.0, v5.0, v4.4
|
||||||||||||||||
| Sprint: | QO 2023-05-15, QO 2023-05-29, QO 2023-06-12, QO 2023-06-26, QO 2023-07-10 | ||||||||||||||||
| Participants: | |||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||
| Description |
|
Sample data:
Index must be present to trigger the bug:
Query in question:
Without the index, it matches two documents. With index but without (redundant) $exists:true inside $elemMatch it also returns two documents. But with index and with redundant exists it fails to return any documents. |
| Comments |
| Comment by Githook User [ 28/Aug/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'Svilen Mihaylov', 'email': '60888594+svilen-mihaylov@users.noreply.github.com', 'username': 'svilen-mihaylov'}Message: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 26/Jul/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'Svilen Mihaylov', 'email': '60888594+svilen-mihaylov@users.noreply.github.com', 'username': 'svilen-mihaylov'}Message: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 25/Jul/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'Svilen Mihaylov', 'email': '60888594+svilen-mihaylov@users.noreply.github.com', 'username': 'svilen-mihaylov'}Message: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 03/Jul/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'Svilen Mihaylov', 'email': '60888594+svilen-mihaylov@users.noreply.github.com', 'username': 'svilen-mihaylov'}Message: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 28/Jun/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'Svilen Mihaylov', 'email': '60888594+svilen-mihaylov@users.noreply.github.com', 'username': 'svilen-mihaylov'}Message: | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Asya Kamsky [ 16/Mar/23 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Here is explain winning plan which shows some funky rewrite happening that doesn't match actual data:
|