Regression with large bulk writes in v2.1

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Gone away
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: CRUD
    • None
    • None
    • Go Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Detailed steps to reproduce the problem?

      Driver version 2.1 introduces a regression with collection.BulkWrite with very large BSON documents. This program reproduces the problem: this program passes with driver version 2.0 but fails on 2.1 with a BSONObjectTooLarge error.

      With driver version 2.0.1, that program prints:

      2025/06/10 10:44:29 command started: dropDatabase
      2025/06/10 10:44:29 command started: update
      2025/06/10 10:44:29 command started: update
      2025/06/10 10:44:29 command started: update
      9
      

      (Three updates, then a succesful response with 9 upserts)

      With driver version 2.1.0 and 2.2.2, it prints

      2025/06/10 10:44:43 command started: dropDatabase
      2025/06/10 10:44:44 command started: update
      2025/06/10 10:44:44 (BSONObjectTooLarge) BSON size limit hit while building Message. Size: 18874889 (0x1200209); maxSize: 16793600(16MB)
      exit status 1
      

      (Error on the first and only update.)

      It seems like something has gone wrong with splitting the bulk write into batches, but that's a guess.

      Definition of done: what must be done to consider the task complete?

      collection.BulkWrite with very large documents should not fail with BSONObjectTooLarge errors.

      The exact Go version used, with patch level:

      Tested on go 1.24.3 and go 1.23.8, same result on both

      The exact version of the Go driver used:

      • v2.0.1 (good)
      • v2.1.0 (broken)
      • v2.2.2 (broken)

      Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.

      I'm testing on a local 3-node replica set with MongoDB 8.0. I've also seen the same problem in Mongo 7.0 and with sharded clusters.

      The operating system and version (e.g. Windows 7, OSX 10.8, ...)

      I'm on macOS 15.5 (but I would be surprised if this were OS related).

            Assignee:
            Qingyang Hu
            Reporter:
            Michael McClimon
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: