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

Update command response does not properly reflect number of documents updated when updating a document fails due to exceeding the BSON size limit

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query Execution
    • ALL
    • Hide
      MongoDB Enterprise > db.c.insert({_id: 0, a: 0})
      WriteResult({ "nInserted" : 1 })
      MongoDB Enterprise > db.c.insert({_id: 1, a: 0, b: "i".repeat(1024*1024*10)})
      WriteResult({ "nInserted" : 1 })
      MongoDB Enterprise > db.c.insert({_id: 2, a: 0})
      WriteResult({ "nInserted" : 1 })
      MongoDB Enterprise > db.runCommand({update: "c", updates: [{q: {a: 0}, u: {$set: {c: "j".repeat(1024*1024*10)}}, multi: true}]})
      {
      	"n" : 0,
      	"writeErrors" : [
      		{
      			"index" : 0,
      			"code" : 10334,
      			"errmsg" : "BSONObj size: 20971565 (0x140002D) is invalid. Size must be between 0 and 16793600(16MB) First element: _id: 1.0"
      		}
      	],
      	"nModified" : 0,
      	"ok" : 1
      }
      MongoDB Enterprise > db.c.find({c: {$exists: true}}).itcount()
      1
      MongoDB Enterprise > db.c.find({c: {$exists: true}}).toArray()[0]._id
      0
      
      Show
      MongoDB Enterprise > db.c.insert({_id: 0, a: 0}) WriteResult({ "nInserted" : 1 }) MongoDB Enterprise > db.c.insert({_id: 1, a: 0, b: "i".repeat(1024*1024*10)}) WriteResult({ "nInserted" : 1 }) MongoDB Enterprise > db.c.insert({_id: 2, a: 0}) WriteResult({ "nInserted" : 1 }) MongoDB Enterprise > db.runCommand({update: "c", updates: [{q: {a: 0}, u: {$set: {c: "j".repeat(1024*1024*10)}}, multi: true}]}) { "n" : 0, "writeErrors" : [ { "index" : 0, "code" : 10334, "errmsg" : "BSONObj size: 20971565 (0x140002D) is invalid. Size must be between 0 and 16793600(16MB) First element: _id: 1.0" } ], "nModified" : 0, "ok" : 1 } MongoDB Enterprise > db.c.find({c: {$exists: true}}).itcount() 1 MongoDB Enterprise > db.c.find({c: {$exists: true}}).toArray()[0]._id 0
    • QE 2021-08-23, QE 2021-09-06, QE 2021-09-20, QE 2021-10-04, QE 2021-10-18, QE 2021-11-01, QE 2021-11-15, QE 2021-11-29, QE 2021-12-13, QE 2021-12-27, QE 2022-01-10, QE 2022-04-04, QE 2022-03-21, QE 2022-01-24, QE 2022-04-18, QE 2022-05-02, QE 2022-05-16, QE 2022-05-30

      When attempting to update a document fails due to exceeding the BSON size limit, the number documents that were successfully updated before reaching the failing document are not reflected in the update command response; instead, it reports that 0 documents were updated. I have not tested whether this affects other types of write errors as well.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            gregory.noma@mongodb.com Gregory Noma
            Votes:
            0 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated: