From e1ef342a615c3cb296f449fe4b6528785329a265 Mon Sep 17 00:00:00 2001 From: Jian Guan <61915096+tdq45gj@users.noreply.github.com> Date: Tue, 7 Apr 2026 13:05:58 -0400 Subject: [PATCH] Update buffered_bulk.go --- common/db/buffered_bulk.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/db/buffered_bulk.go b/common/db/buffered_bulk.go index d0cb922a7..3b68a525b 100644 --- a/common/db/buffered_bulk.go +++ b/common/db/buffered_bulk.go @@ -77,8 +77,10 @@ func newBufferedBulkInserter( docLimit: docLimit, // We set the byte limit to be slightly lower than maxMessageSizeBytes so it can fit in one OP_MSG. // This may not always be perfect, e.g. we don't count update selectors in byte totals, but it should - // be good enough to keep memory consumption in check. - byteLimit: MAX_MESSAGE_SIZE_BYTES - 100, + // be good enough to keep memory consumption in check. Because we cannot reliably predict the total + // size of the message that will be sent by the go-driver, the 1MB buffer for message overhead is + // a conservative estimate chosen arbitrarily. + byteLimit: MAX_MESSAGE_SIZE_BYTES - 1_000_000, writeModels: make([]mongo.WriteModel, 0, docLimit), canDoZeroTimestamp: zeroTimestampOk, }