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

Improved SearchContext.addReleasable. #5799

Closed
wants to merge 3 commits into from
Closed

Conversation

jpountz
Copy link
Contributor

@jpountz jpountz commented Apr 14, 2014

For resources that have their life time effectively defined by the search
context they are attached to, it is convenient to use the search context to
schedule the release of such resources.

This commit changes aggregations to use this mechanism and also introduces
a Lifetime object that can be used to define how long the object should
live:

  • COLLECTION: if the object only needs to live during collection time and is
    what SearchContext.addReleasable would have chosen before this change
    (used for p/c queries),
  • PHASE for resources that only need to live during the current search
    phase (DFS, QUERY or FETCH),
  • CONTEXT for resources that need to live until the context is
    destroyed.

Aggregators are currently registed with CONTEXT. The reason is that when
using the DFS_QUERY_THEN_FETCH search type, they are allocated during the DFS
phase but only used during the QUERY phase. However we should fix it in order
to only allocate them during the QUERY phase and use PHASE as a life
time.

Close #5703

For resources that have their life time effectively defined by the search
context they are attached to, it is convenient to use the search context to
schedule the release of such resources.

This commit changes aggregations to use this mechanism and also introduces
a `Lifetime` object that can be used to define how long the object should
live:
 - COLLECTION: if the object only needs to live during collection time and is
   what SearchContext.addReleasable would have chosen before this change
   (used for p/c queries),
 - SEARCH_PHASE for resources that only need to live during the current search
   phase (DFS, QUERY or FETCH),
 - SEARCH_CONTEXT for resources that need to live until the context is
   destroyed.

Aggregators are currently registed with SEARCH_CONTEXT. The reason is that when
using the DFS_QUERY_THEN_FETCH search type, they are allocated during the DFS
phase but only used during the QUERY phase. However we should fix it in order
to only allocate them during the QUERY phase and use SEARCH_PHASE as a life
time.

Close elastic#5703
/**
* This life time is for objects that need to live until the end of the current search phase.
*/
SEARCH_PHASE,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe call them COLLECTION, PHASE, CONTEXT since they are true subsets?

@s1monw
Copy link
Contributor

s1monw commented Apr 14, 2014

I left some style issue comments but this looks very good!

@jpountz
Copy link
Contributor Author

jpountz commented Apr 14, 2014

@s1monw I just pushed new commits

@s1monw
Copy link
Contributor

s1monw commented Apr 14, 2014

LGTM

@jpountz jpountz closed this Apr 14, 2014
@jpountz jpountz deleted the fix/5703 branch April 14, 2014 15:51
@clintongormley clintongormley added >bug v2.0.0-beta1 v1.2.0 :Search/Search Search-related issues that do not fall into other categories labels Jun 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories v1.2.0 v2.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failures in constructing aggs can cause pages not to be released
3 participants