-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
Fully Compatible
-
ALL
-
(copied to CRM)
ISSUE DESCRIPTION AND IMPACT
In MongoDB version 6.0.17, some large aggregation pipelines may return incorrect results, cause a mongod or mongos to crash, or raise an error when it did not previously. Affected aggregation pipelines are those that:
- Exceed 30,000 bytes in size, and
- Contain at least one $group and/or $lookup stage near the beginning of the pipeline, potentially preceded by a $match, $project, $addFields or $sort stage
Affected operations may omit one or more $group or $lookup stages in the aggregation pipeline, resulting in operations that return incorrect results or generate errors.
DIAGNOSIS AND AFFECTED VERSIONS
MongoDB Server version 6.0.17 is subject to the bug. No other versions are affected.
REMEDIATION AND WORKAROUNDS
Customers are advised to:
- Upgrade to 6.0.18, or
- Customers staying on 6.0.17 should set the internalQueryForceClassicEngine parameter to true with the following command:
db.adminCommand({setParameter: 1, internalQueryForceClassicEngine: true})
Original description
Prior to SPM-2697 (which shipped as part of v7.0), for queries containing hundreds of expressions, the SBE stage builder was prone to generate very deep SBE plan trees in some scenarios. For $group specifically, it's pretty easy to get the SBE stage builder to generate very deep SBE plan trees which will stack overflow during execution (as shown in [^stack-overflow-example-group-query.txt]).
The goal of this task is to implement a solution to this problem so that these kinds of queries won't crash on v6.0. If v5.0 is affected by this issue, we may also need to backport the fix to v5.0 as well.
- is related to
-
SERVER-91617 Simplify $ifNull stage builder generation in 6.0
- Closed
- related to
-
SERVER-94908 Group stage in aggregation pipeline act as a project stage
- Closed
-
SERVER-94170 Revert SERVER-91570
- Closed
-
SERVER-94762 Audit and improve the Server's downgrade procedure and downgrade testing
- Needs Scheduling