[SERVER-13661] Increase the maximum allowed depth of query objects Created: 18/Apr/14  Updated: 11/Jul/16  Resolved: 21/Apr/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.6.0
Fix Version/s: 2.6.1, 2.7.0

Type: Task Priority: Minor - P4
Reporter: David Storch Assignee: David Storch
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-15559 Fatal Exception: Deeply nested $cond ... Closed
Backport Completed:
Participants:

 Description   
Issue Status as of April 21, 2014

ISSUE SUMMARY
The limit for the recursive tree depth of query documents currently is only 10 levels deep. While most queries should not be affected by this issue, certain auto-generated queries, for example from ORM mappers, can construct complex nested query documents and hit the limit.

USER IMPACT
In 2.4 the limit was not strictly enforced, so users may find some of their queries to be rejected after upgrading to 2.6.

WORKAROUNDS
Manual queries with a high tree depth often can be reduced to a flatter version, for example by removing nested $and predicates and instead adding the conditions to a single $and statement.

RESOLUTION
This patch increases the tree depth from 10 to 100 and brings it in line with the value documented on the MongoDB Limits and Thresholds page.

AFFECTED VERSIONS
MongoDB 2.6.0 is affected by this bug.

PATCHES
The patch is included in the 2.6.1 production release.

Original description

Right now the number of recursive calls is limited to 20 in parsing (which corresponds to a maximum allowed tree depth of 10):

https://github.com/mongodb/mongo/blob/019c401589b34b46bf7bec801e23bd3dd7796151/src/mongo/db/matcher/expression_parser_tree.cpp#L46

Some autogenerated queries may hit this limit, so let's make it higher.



 Comments   
Comment by Githook User [ 21/Apr/14 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-13661 increase the maximum allowed depth for query objects
(cherry picked from commit a4fc6b326793de8aaa1301c1c7f20ef71e2d03ea)
Branch: v2.6
https://github.com/mongodb/mongo/commit/66da6ee14e6de327285f76ae73e48a56788ab901

Comment by Githook User [ 21/Apr/14 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-13661 increase the maximum allowed depth for query objects
Branch: master
https://github.com/mongodb/mongo/commit/a4fc6b326793de8aaa1301c1c7f20ef71e2d03ea

Generated at Thu Feb 08 03:32:28 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.