[SERVER-24546] Explain() fails if negative batchSize value is specified Created: 14/Jun/16  Updated: 06/Dec/22  Resolved: 14/Jun/16

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

Type: Bug Priority: Minor - P4
Reporter: Dmitry Ryabtsev Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-21814 In "commands" readMode, shell should ... Closed
Assigned Teams:
Query
Operating System: ALL
Participants:

 Description   

The documentation says that cursor.batchSize() takes negative arguments.

"3.2.6"

> db.version()
3.2.6
> version()
3.2.6
> db.testcol.find().batchSize(-5)
Error: error: {
	"waitedMS" : NumberLong(0),
	"ok" : 0,
	"errmsg" : "batchSize value must be non-negative",
	"code" : 2
}
> db.testcol1.explain().find().batchSize(-5)
2016-06-14T13:56:00.545+1000 E QUERY    [thread1] Error: explain failed: { "ok" : 0, "errmsg" : "batchSize value must be non-negative", "code" : 2 } :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
throwOrReturn@src/mongo/shell/explainable.js:31:1
constructor/this.finish@src/mongo/shell/explain_query.js:176:24
constructor/this.shellPrint@src/mongo/shell/explain_query.js:215:26
shellPrintHelper@src/mongo/shell/utils.js:489:1
@(shell2):1:1

"3.0.12"

> db.testcol.find().batchSize(-10)
{ "_id" : ObjectId("575f809faa700ec9ca969857"), "a" : 0, "b" : "text" }
{ "_id" : ObjectId("575f809faa700ec9ca969858"), "a" : 1, "b" : "text" }
{ "_id" : ObjectId("575f809faa700ec9ca969859"), "a" : 2, "b" : "text" }
{ "_id" : ObjectId("575f809faa700ec9ca96985a"), "a" : 3, "b" : "text" }
{ "_id" : ObjectId("575f809faa700ec9ca96985b"), "a" : 4, "b" : "text" }
{ "_id" : ObjectId("575f809faa700ec9ca96985c"), "a" : 5, "b" : "text" }
{ "_id" : ObjectId("575f809faa700ec9ca96985d"), "a" : 6, "b" : "text" }
{ "_id" : ObjectId("575f809faa700ec9ca96985e"), "a" : 7, "b" : "text" }
{ "_id" : ObjectId("575f809faa700ec9ca96985f"), "a" : 8, "b" : "text" }
{ "_id" : ObjectId("575f809faa700ec9ca969860"), "a" : 9, "b" : "text" }
> db.testcol.explain().find().batchSize(-10)
2016-06-14T13:58:06.721+1000 E QUERY    Error: explain failed: { "ok" : 0, "errmsg" : "batchSize value must be positive", "code" : 2 }
    at Error (<anonymous>)
    at Function.throwOrReturn (src/mongo/shell/explainable.js:34:19)
    at constructor.finish (src/mongo/shell/explain_query.js:188:36)
    at constructor.shellPrint (src/mongo/shell/explain_query.js:228:31)
    at shellPrintHelper (src/mongo/shell/utils.js:396:18)
    at (shell2):1:19 at src/mongo/shell/explainable.js:34

I am not sure if which behaviour is desired, if it's the one we have with 3.2 please move this ticket into DOCS.



 Comments   
Comment by Dmitry Ryabtsev [ 14/Jun/16 ]

The shell 3.0 behavior cannot be correct as explain() is failing to accept negative batchSize() (which is a valid value according to the doc).

Generated at Thu Feb 08 04:06:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.