[SERVER-21814] In "commands" readMode, shell should translate negative batchSize to positive batchSize + singleBatch Created: 09/Dec/15  Updated: 05/Oct/16  Resolved: 04/Feb/16

Status: Closed
Project: Core Server
Component/s: Querying, Shell
Affects Version/s: None
Fix Version/s: 3.3.2

Type: Bug Priority: Minor - P4
Reporter: David Storch Assignee: Benjamin Murphy
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-24546 Explain() fails if negative batchSize... Closed
Related
related to RUBY-1147 Error when sending getMore command on... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Query F (02/01/16), Query 10 (02/22/16)
Participants:

 Description   

Historically the shell has accepted a negative value for batchSize and passed this through to the server as a negative "ntoreturn" value. The query

db.collection.find().batchSize(-8);

means return up to 8 documents in the initial response batch, and then close the cursor.

When the shell is configured with --readMode commands, however, it currently passes the negative batchSize through to the server as a find command parameter. The server's find command implementation rejects negative batchSize:

> db.c.drop()
true
> db.c.insert({a: 1})
WriteResult({ "nInserted" : 1 })
> db.c.find().batchSize(-1)
Error: error: {
	"waitedMS" : NumberLong(0),
	"ok" : 0,
	"errmsg" : "batchSize value must be non-negative",
	"code" : 2
}

This behavior is inconsistent with the drivers find command specification for the behavior of limit, skip, and batchSize. Instead, the shell should translate a batchSize of -n to a batchSize of +n with the singleBatch option set to true.



 Comments   
Comment by Githook User [ 04/Feb/16 ]

Author:

{u'username': u'benjaminmurphy', u'name': u'Benjamin Murphy', u'email': u'benjamin_murphy@me.com'}

Message: SERVER-21814 Shell correctly processes negative batchSize in commands readMode.
Branch: master
https://github.com/mongodb/mongo/commit/2b9bc34d1d5f61c0d25b20a393462404c3802125

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