[SERVER-14289] Invalid limit for delete command should result in write error Created: 17/Jun/14  Updated: 03/Mar/15  Resolved: 13/Feb/15

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 2.6.2
Fix Version/s: 2.7.7

Type: Bug Priority: Major - P3
Reporter: Jeremy Mikola Assignee: Unassigned
Resolution: Done Votes: 0
Labels: pull-request
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

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).



 Comments   
Comment by Jeremy Mikola [ 13/Feb/15 ]

benety.goh: should this still be unresolved? The PR was merged.

Comment by Githook User [ 19/Sep/14 ]

Author:

{u'username': u'Michael-karn-ivanov', u'name': u'Michael Ivanov', u'email': u'michael.karn.ivanov@gmail.com'}

Message: SERVER-14289 invalid limit for delete command should result in write error

Closes #775

Signed-off-by: Benety Goh <benety@mongodb.com>
Branch: master
https://github.com/mongodb/mongo/commit/6246d74016340261493d6606a6f0a708c39395cc

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