[SERVER-7267] Batch size + sort closes the cursor Created: 05/Oct/12  Updated: 12/Jun/14  Resolved: 07/Oct/12

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

Type: Bug Priority: Major - P3
Reporter: Gustavo Niemeyer Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-5374 batchSize is a hard limit for an in m... Closed
Related
related to SERVER-14228 Setting batchSize and sort on a curso... Closed
Operating System: ALL
Participants:

 Description   

Batch size becomes limit if sort is appended to it:

> db.test.insert(

{n: 1}

)
> db.test.insert(

{n: 2}

)
> db.test.insert(

{n: 3}

)
> db.test.insert(

{n: 4}

)
> db.test.insert(

{n: 5}

)

> db.test.find().batchSize(2).sort(

{n: 1}

)

{ "_id" : ObjectId("506e43b5681e3dfd1b92980b"), "n" : 1 } { "_id" : ObjectId("506e43b7681e3dfd1b92980c"), "n" : 2 }

> db.test.find().batchSize(2)

{ "_id" : ObjectId("506e43b5681e3dfd1b92980b"), "n" : 1 } { "_id" : ObjectId("506e43b7681e3dfd1b92980c"), "n" : 2 } { "_id" : ObjectId("506e43b8681e3dfd1b92980d"), "n" : 3 } { "_id" : ObjectId("506e43b9681e3dfd1b92980e"), "n" : 4 } { "_id" : ObjectId("506e43ba681e3dfd1b92980f"), "n" : 5 }

The problem seems to be in the server. I can reproduce the same issue with the Go driver.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 07/Oct/12 ]

SERVER-5374

Comment by Gustavo Niemeyer [ 05/Oct/12 ]

This is probably related to mongo refusing to return a cursor with in-memory sorts.

It'd be nice to make the behavior more user-friendly somehow to avoid the surprise.

Generated at Thu Feb 08 03:14:03 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.