[SERVER-78914] multi-deletes might return incorrect 'n' deleted count when there is an error Created: 13/Jul/23  Updated: 02/Feb/24

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

Type: Bug Priority: Major - P3
Reporter: Arun Banala Assignee: Backlog - Query Execution
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-58738 Update command response does not prop... Backlog
Assigned Teams:
Query Execution
Operating System: ALL
Steps To Reproduce:

> db.test.insertMany([{x: NumberInt("2")}, {x: "1,200"}])
{
	"acknowledged" : true,
	"insertedIds" : [
		ObjectId("64af67c7b991883f3227645d"),
		ObjectId("64af67c7b991883f3227645e")
	]
}
> db.runCommand({delete: 'test', deletes: [{q: {$expr: {$toDecimal: "$x"}}, limit: 0}]})
{
	"n" : 0, // This should be 1.
	"writeErrors" : [
		{
			"index" : 0,
			"code" : 241,
			"errmsg" : "Failed to parse number '1,200' in $convert with no onError value: Failed to parse string to decimal"
		}
	],
	"ok" : 1
}
> db.test.find()
{ "_id" : ObjectId("64af67c7b991883f3227645e"), "x" : "1,200" }

Sprint: QE 2023-08-07, QE 2023-08-21, QE 2023-09-04, QE 2023-09-18, QE 2023-10-02, QE 2023-10-16, QE 2023-10-30, QE 2023-11-13, QE 2023-11-27, QE 2023-12-11, QE 2023-12-25, QE 2024-01-08, QE 2024-01-22, QE 2024-02-05, QE 2024-02-19
Participants:

 Description   

I've noticed that the mutli-deletes doesn't not report the count of already deleted objects. I understand that it is hard to provide guarantees when an operation fails, but the previous deleted objects should not be affected by the current delete failure. This is also inconsistent with how a sharded cluster deals with errors across shards. In a case where there are errors from one shard and success from other shards, mongos would merge the results from the shards and report correct 'n' delete count.

I assume we will have a similar problem with multi-updates


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