-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: whereField creates a memory leak #12972
base: main
Are you sure you want to change the base?
Conversation
Coverage Report 1Affected Products
Test Logs |
Hi @ehsannas , could you please review this fix? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for not providing GetFlattenFilter() in base filter class is creating flatten filter in field filter constructor will cause infinity loop.
why? maybe you shouldn't call GetFlattenedFilters()
in the constructor, but should still have GetFlattenedFilters()
defined for field filters [which just returns *this].
@ehsannas I put back |
// field filter, calling for (const FieldFilter& subFilter : | ||
// *filter.GetFlattenedFilters()) will deference a temporary object. | ||
auto flattened_filters_ptr = filter.GetFlattenedFilters(); | ||
for (const FieldFilter& field_filter : *flattened_filters_ptr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Don't deference filter.GetFlattenedFilters() directly. if the filter is a
// field filter, calling for (const FieldFilter& subFilter :
// *filter.GetFlattenedFilters()) will deference a temporary object.
This is the result of bad design and devs can't be expected to "do the right thing" by reading the comment.
why can't field filters follow the same pattern as composite filters to avoid this problem?
please reach out offline if you think more discussion is needed. Thanks!
fix: #12613
revert the thread safe memoizer introduced in this pr: #11781
@cherylEnkidu :
This PR intends to fix the data race and memory leak issue.
When using memorized field, it leads to data race. However, the solution for fixing data race issue introduces memory leak.
So this PR construct a flatten filters for composite filter during initialization.
The reason for not providing
GetFlattenFilter()
in base filter class is creating flatten filter in field filter constructor will cause infinity loop.Since
GetFlattenFilter()
is widely used in query calls, initflatten filters vector
in composite filter during construction won't hurt efficiency a lot comparing to constructflatten filters vector
upon request.