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

Invalid limit for delete command should result in write error

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.7.7
    • Affects Version/s: 2.6.2
    • Component/s: Write Ops
    • Fully Compatible
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      According to the write command spec, 1 and 0 are the only permissible values for the delete command's "limit" option. Unexpectedly, the server treats any value other than 1 as "no limit":

      > db.foo.drop();
      true
      > db.runCommand({insert:"foo",documents:[{x:1},{x:2},{x:3}]})
      { "ok" : 1, "n" : 3 }
      > db.foo.find()
      { "_id" : ObjectId("53a0971a3d971a72e86ca57f"), "x" : 1 }
      { "_id" : ObjectId("53a0971a3d971a72e86ca580"), "x" : 2 }
      { "_id" : ObjectId("53a0971a3d971a72e86ca581"), "x" : 3 }
      > db.runCommand({delete:"foo",deletes:[{q:{},limit:2}]})
      { "ok" : 1, "n" : 3 }
      > db.foo.find()
      > 
      

      Until the server does support deletion limits, it would be safer to return a write error in this case (similar to what is currently done if the "limit" option is missing entirely).

            Assignee:
            Unassigned Unassigned
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: