Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-21814

In "commands" readMode, shell should translate negative batchSize to positive batchSize + singleBatch

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.3.2
    • Affects Version/s: None
    • Component/s: Querying, Shell
    • Fully Compatible
    • ALL
    • Query F (02/01/16), Query 10 (02/22/16)

      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.

            Assignee:
            benjamin.murphy Benjamin Murphy
            Reporter:
            david.storch@mongodb.com David Storch
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: