[SERVER-33107] Incorrect result while using pipeline with skip and limit Created: 03/Feb/18 Updated: 28/Feb/18 Resolved: 05/Feb/18 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Aggregation Framework |
| Affects Version/s: | 3.6.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Yaroslav | Assignee: | Mark Agarunov |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
db.version() --> 3.6.2 |
||
| Attachments: |
|
||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||
| Steps To Reproduce: | STR:
Expected result: the documents with ids 6 and 7 are returned as in chained query
Actual result: the documents with ids 3 and 5 are returned |
||||||||||||||||||||
| Participants: | |||||||||||||||||||||
| Description |
|
I was trying to use an aggregation pipeline in the following order: In my case: I expected to see last 2 documents from the match result, but the query returned 2-nd and 4-th documents from the match result. If I set a limit to 3, then everything works as expected (I receive last 2 documents). The other way to get a correct result is to add an _id : 1 as the last sort column in sort step or exclude sort step at all. If I use simple chaining like .find().sort().skip().limit() it works correct too. |
| Comments |
| Comment by Mark Agarunov [ 05/Feb/18 ] |
|
Hello iamyardem, Thank you for the report. Looking over the behavior described, I believe this expected behavior as described in Thanks, |