Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

milaGGL
Copy link
Contributor

@milaGGL milaGGL commented May 15, 2024

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, init flatten filters vector in composite filter during construction won't hurt efficiency a lot comparing to construct flatten filters vector upon request.

@google-oss-bot
Copy link

google-oss-bot commented May 15, 2024

Coverage Report 1

Affected Products

  • FirebaseFirestore-iOS-FirebaseFirestoreInternal.framework

    Overall coverage changed from 88.14% (9be3928) to 88.20% (77ff64d) by +0.06%.

    FilenameBase (9be3928)Merge (77ff64d)Diff
    composite_filter.cc90.10%87.76%-2.34%
    exception.cc23.68%84.21%+60.53%
    field_filter.cc95.00%94.55%-0.45%
    filter.cc70.00%62.50%-7.50%
    leveldb_key.cc99.02%98.63%-0.39%
    leveldb_mutation_queue.cc93.56%92.42%-1.14%
    local_serializer.cc87.78%88.33%+0.56%
    query_core.cc95.80%95.91%+0.11%
    target.cc96.23%96.35%+0.12%

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/V7ZyS0seKZ.html

@cherylEnkidu
Copy link
Contributor

Hi @ehsannas , could you please review this fix?

Copy link
Contributor

@ehsannas ehsannas left a 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 ehsannas assigned cherylEnkidu and unassigned ehsannas May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GetDocuments: whereField creates a memory leak.
4 participants