[SERVER-51725] Duplicate documents while using "Sort" with "Pagination" Created: 19/Oct/20  Updated: 15/Dec/20  Resolved: 04/Nov/20

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 4.4.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Ummer Irshad Assignee: Edwin Zhou
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-51498 Sorting on duplicate values causes re... Closed
Related
Operating System: ALL
Steps To Reproduce:

Environment with Issue

Server : Windows Server 2016
mongo db version: 4.4.0
driver: 2.10.2

 

Step

  • Query a collection with more than 50 documents with SortByDescending and Pagination (page size 10)

Result

  • Duplicate documents are returned by the driver from second page onwards.
Participants:

 Description   

When we query MongoDB in below environment with SortByDescending and Pagination, MongoCSharp driver is always returning duplicate documents from the second page onwards. We are setting page size as 10.

Issue is not observed when we remove SortByDescending.

Environment with Issue

Server : Windows Server 2016
mongo db version: 4.4.0
driver: 2.10.2

 

Environment without Issue

Server : Windows Server 2016
mongo db version: 4.0.6
driver: 2.10.2



 Comments   
Comment by Edwin Zhou [ 04/Nov/20 ]

ummerirshadk@gmail.com,

I'm happy to hear that! I'll be closing this ticket as a duplicate of SERVER-28195 now that it's been resolved.

Best,

Edwin

Comment by Ummer Irshad [ 04/Nov/20 ]

After sorting on unique field (ObjectId) the issue is not reproduced. Thanks a lot Edwin Zhou. 

Comment by Edwin Zhou [ 03/Nov/20 ]

Hi ummerirshadk@gmail.com,

We still need additional information to diagnose the problem. If this is still an issue for you, would you please let me know if SERVER-28195 is representative of your problem? Could you provide a code snippet where this problem occurs so we can understand if this is a driver specific problem? Would you also inform us if the problem persists if you sort on a unique field?

Best,

Edwin

Comment by Edwin Zhou [ 19/Oct/20 ]

Hi ummerirshadk@gmail.com,

Thank you for reporting this behavior! Could you provide a code snippet where this issue is occurs, and your query result?
I suspect this is a duplicate of SERVER-28195 and this behavior is expected in MongoDB 4.4. Does this ticket describe your issue?
This issue usually occurs when sorting on a field that contains multiple of the same value, and using skip and limit. To avoid duplicates, please try sorting on an additional unique field, e.g. _id. 

Edwin

Generated at Thu Feb 08 05:26:15 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.