[SERVER-78342] nReturned in slow query is incorrect when no docs are matched Created: 22/Jun/23 Updated: 29/Oct/23 Resolved: 16/Aug/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 7.1.0-rc0, 5.0.22, 7.0.3, 6.0.12 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Adi Agrawal | Assignee: | Adi Agrawal |
| 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.0, v5.0, v4.4
|
||||||||
| Sprint: | QE 2023-07-10, QE 2023-07-24, QE 2023-08-07, QE 2023-08-21 | ||||||||
| Participants: | |||||||||
| Description |
|
To reproduce this behavior:
Now run:
The slow query log for this is:
This will give nReturned = 3 which is the total number of docs and not the number of docs matched. Note that this does not happen when there is only a match stage. It happens if addFields comes before match (I haven't checked other stages that could potentially cause the same issue) |
| Comments |
| Comment by Githook User [ 12/Oct/23 ] |
|
Author: {'name': 'Adityavardhan Agrawal', 'email': 'adi.agrawal@mongodb.com', 'username': 'Adityav369'}Message: (cherry picked from commit 6fe23ef017834f0c962f6e8672fd75f2f2e652b1) |
| Comment by Githook User [ 11/Oct/23 ] |
|
Author: {'name': 'Adityavardhan Agrawal', 'email': 'adi.agrawal@mongodb.com', 'username': 'Adityav369'}Message: (cherry picked from commit 6fe23ef017834f0c962f6e8672fd75f2f2e652b1) |
| Comment by Githook User [ 11/Oct/23 ] |
|
Author: {'name': 'Adityavardhan Agrawal', 'email': 'adi.agrawal@mongodb.com', 'username': 'Adityav369'}Message: (cherry picked from commit 6fe23ef017834f0c962f6e8672fd75f2f2e652b1) |
| Comment by Githook User [ 16/Aug/23 ] |
|
Author: {'name': 'Adityavardhan Agrawal', 'email': 'adi.agrawal@mongodb.com', 'username': 'Adityav369'}Message: |