-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 2.4.5
-
Component/s: Aggregation Framework
-
None
-
Environment:Win2008R2
3-node replica set
-
Fully Compatible
-
ALL
ISSUE SUMMARY
Memory leak in aggregation in MutableDocument::setNestedField
USER IMPACT
This leak can manifest in two different scenarios:
- Accessing nested fields in the original document fetched from the collection. This leads to a leak of a few hundred bytes per aggregation command. The amount of memory leaked in this case does not depend on the amount of data processed in the aggregation. If the nested fields are only used by a $match expression but not any other pipeline stages, this leak does not apply.
- Using a $geoNear pipeline stage and using distanceField or includeLocs to inject information into a nested field. This results in a leak of a few hundred bytes per document returned from geoNear.
It is present in versions of MongoDB prior to and including v2.4.6.
SOLUTION
Fix ref counting of NULL pointers in MutableDocument.
WORKAROUNDS
None.
PATCHES
Production release v2.4.7 contains the fix for this issue, and production release v2.6.0 will contain the fix as well.
Original Description
Aggregation queries are causing memory leak on primary. Detected by comparing umdh memory dumps before and after running aggregation.
There are two cases in the current codebase that can cause this leak:
1) Accessing nested fields in the original document fetched from the collection. This leads to a leak of a few hundred bytes per aggregation command. The amount of memory leaked in this case does not depend on the amount of data processed in the aggregation. If the nested fields are only used by a $match expression but not any other pipeline stages, this leak does not apply.
2) Using a $geoNear pipeline stage and using distanceField or includeLocs to inject information into a nested field. This results in a leak of a few hundred bytes per documented returned from geoNear.