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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.3.2
    • Component/s: Querying, Shell
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      Query F (02/01/16), Query 10 (02/22/16)

      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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved: