MongoDB 4.4.15 - BSONObjectTooLarge - aggregation $out update

MongoDB 4.4.15

When updating a $out (aggregation) on a primary node it runs successful.
When running the same $out aggregation using a secondary node we get this error:

BSONObj size: 16953146 (0x102AF3A) is invalid.
Size must be between 0 and 16793600(16MB) First element:
insert: " tmp.agg_out.55125f65 - 0ef0 - 4c1f - a7ef - dec311c99612 "

According the 4.4 manual https://www.mongodb.com/docs/v4.4/reference/operator/aggregation/out/#behaviors I was under the impression this was possible but I cannot find any information regarding a possible size restriction causing this error.

Is this expected behaviour?

Thanks,
L

Hi @Lars_Van_Casteren,

The issue you’re experiencing is likely the result of SERVER-66289, which was fixed in MongoDB 6.1.

TL;DR of this issue is that though $out can target secondary nodes in 4.4, on occasion when more than 16MB of documents need to be written (the BSON Document Max Size) even with buffering of writes there is a small amount of overhead that can push a batch over this threshold. This overhead is not present when targeting a PRIMARY node, which is why the issue only exists when run on a SECONDARY.

We’ve requested this fix be backported to 6.0, 5.0 and 4.4 however this has not yet been completed.

1 Like

Hello @alexbevi ,

Thanks for your reply!

We’re unable to move to 5.x or 6.x for the moment so I guess we’ll have to wait for the backport to 4.4.

Gt,
L

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.