-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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 memory leak when percolator uses bitset or field data cache #24115
Fix memory leak when percolator uses bitset or field data cache #24115
Conversation
@Override | ||
@SuppressWarnings("unchecked") | ||
public <IFD extends IndexFieldData<?>> IFD getForField(MappedFieldType fieldType) { | ||
IndexFieldData.Builder builder = fieldType.fielddataBuilder(); |
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.
Still need to think how to add a test for this too...
Ideally we would use the |
@jpountz What do you think about adding a |
If you can find a way to do that, that would be great! |
ef6fe92
to
461767b
Compare
@jpountz what do you think of the current approach in this pr? |
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.
Thanks for looking into it, I think what you are suggesting would work, we just need to make the wiring a bit nicer?
|
||
public void setDelegate(Consumer<Releasable> delegate) { | ||
this.delegate = delegate; | ||
} |
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.
should it be a constructor arg?
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.
done - it is now a final field
@@ -98,6 +100,10 @@ public void setTypes(String... types) { | |||
private NestedScope nestedScope; | |||
private boolean isFilter; | |||
|
|||
private Consumer<Releasable> delegate = (releasable) -> { |
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.
let's try to make it final and give it a better name?
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.
I don't have suggestions though...
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.
Me neither... I've named it now releaseDelegator
461767b
to
ce08211
Compare
@@ -472,11 +473,19 @@ public IndexSettings getIndexSettings() { | |||
* {@link IndexReader}-specific optimizations, such as rewriting containing range queries. | |||
*/ | |||
public QueryShardContext newQueryShardContext(int shardId, IndexReader indexReader, LongSupplier nowInMillis) { |
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.
should we just remove this one completely?
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.
That method is still being used in other places. For example in MetaDataCreateIndexService
and MetaDataIndexAliasesService
. In these places we don't have access to a search context and we test there if alias filters parse correctly, which means we will not be supporting percolate
queries there, which I think is ok.
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.
I removed this method, wdyt?
c67a66a
to
161661e
Compare
I've reverted this PR back to the initial approach (replacing field data and bitset cache in a custom |
…a cache. The percolator doesn't close the IndexReader of the memory index any more. Prior to 2.x the percolator had its own SearchContext (PercolatorContext) that did this, but that was removed when the percolator was refactored as part of the 5.0 release. I think an alternative way to fix this is to let percolator not use the bitset and fielddata caches, that way we prevent the memory leak. Closes elastic#24108
161661e
to
c17de49
Compare
The percolator doesn't close the IndexReader of the memory index any more.
Prior to 2.x the percolator had its own SearchContext (PercolatorContext) that did this,
but that was removed when the percolator was refactored as part of the 5.0 release.
I think an alternative way to fix this is to let percolator not use the bitset and fielddata caches,
that way we prevent the memory leak.
Adding a WIP label to this as I'm not happy with the current test. It is not easy to test that we don't use the bitset or fielddata cache for the percolator, because non percolator operations may use these caches, which is valid.
PR for #24108