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

multi-deletes might return incorrect 'n' deleted count when there is an error

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • ALL
    • Hide
      > 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" }
      
      Show
      > 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" }
    • 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, QE 2024-03-04, QE 2024-03-18, QE 2024-04-01, QE 2024-04-15, QE 2024-04-29, QE 2024-05-13, QE 2024-05-27, QE 2024-06-10, QE 2024-06-24, QE 2024-07-08, QE 2024-07-22, QE 2024-08-05, QE 2024-08-19, QE 2024-09-02, QE 2024-09-16, QE 2024-09-30, QE 2024-10-14, QE 2024-10-28, QE 2024-11-11, QE 2024-11-25, QE 2024-12-09, QE 2024-12-23, QE 2025-01-06

      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

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            arun.banala@mongodb.com Arun Banala
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: