[DOCS-10578] MongoDB depth levels of nesting for BSON documents Created: 26/Jul/17  Updated: 30/Oct/23  Resolved: 26/Jul/17

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Task Priority: Minor - P4
Reporter: Conchi Bueno Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 6 years, 29 weeks ago

 Description   

Customer is getting an error while performing initial sync in version 3.4.6:

'BSONObj exceeded maximum nested object depth: 200

In MongoDB docs we can see this documented but with *100* levels of nesting:

Nested Depth for BSON Documents.

MongoDB supports no more than 100 levels of nesting for BSON documents.

In the code:

  • mongo/src/mongo/bson/bson_depth.h:

    // The default BSON depth nesting limit.
        static constexpr std::int32_t kDefaultMaxAllowableDepth = 200;

  • mongo/src/mongo/bson/bson_validate.cpp:

    return {ErrorCodes::Overflow,
                                str::stream() << "BSONObj exceeded maximum nested object depth: "
                                              << BSONDepth::getMaxAllowableDepth()};



 Comments   
Comment by Kelsey Schubert [ 26/Jul/17 ]

Hi conchi.bueno,

Due to the way certain commands are rewritten to the oplog, a BSON object that was originally <= 100 levels may exceed the limit. For ease of implementation, we allow for some slack and set the hard limit at 200.

The official advice is still the case that you should restrict your use cases to 100 levels of nesting or less; the server just happens to allow for some slack.

Best regards,
Thomas

Generated at Thu Feb 08 08:00:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.