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

Close query cache on index service creation failure #48230

Merged

Conversation

DaveCTurner
Copy link
Contributor

Today it is possible that we create the QueryCache and then fail to create
the owning IndexService and this means we do not close the QueryCache
again. This commit addresses that leak.

Fixes #48186

Today it is possible that we create the `QueryCache` and then fail to create
the owning `IndexService` and this means we do not close the `QueryCache`
again. This commit addresses that leak.

Fixes elastic#48186
@DaveCTurner DaveCTurner added >bug :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. v8.0.0 v7.5.0 v7.6.0 v7.4.2 v6.8.5 labels Oct 18, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (:Distributed/CRUD)

Copy link
Member

@original-brownbear original-brownbear left a comment

Choose a reason for hiding this comment

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

LGTM :)

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

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

It looks like we can have another leak here ? The index analyzers are created by the IndexService so the build could move to the IndexModule ? These constructors are also not supposed to throw exceptions so it should also be possible to delay the IllegalArgumentException to MapperService#merge ? The exception should be removed in master since it is not applicable anymore so we probably don't need to spend too much time on it but I wonder if the model is safe here since we cannot protect all constructors with closeable object against random runtime exceptions ?

@DaveCTurner
Copy link
Contributor Author

Thanks @jimczi, see ccdc259. I'm wondering about moving the creation of MapperService/IndexFieldDataService/BitsetFilterCache/IndexCache out as well, even though I don't think these leak meaningfully. Makes this change quite a bit larger and adds a bunch more constructor parameters. WDYT?

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

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

LGTM

I'm wondering about moving the creation of MapperService/IndexFieldDataService/BitsetFilterCache/IndexCache out as well, even though I don't think these leak meaningfully. Makes this change quite a bit larger and adds a bunch more constructor parameters. WDYT?

Agreed, maybe add a comment explaining why we expect an exception here and we can clean up when we remove the IllegalArgumentException in MapperService on master ?

Copy link
Contributor

@astefan astefan left a comment

Choose a reason for hiding this comment

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

LGTM

@DaveCTurner
Copy link
Contributor Author

@jimczi Are you sure this exception handling stops being necessary when the obvious IllegalArgumentException goes away? If so, it would be better just to handle that one case. But there's a lot of code here, some of it pluggable, so I would lean towards being defensive and keeping it.

@jimczi
Copy link
Contributor

jimczi commented Oct 18, 2019

Are you sure this exception handling stops being necessary when the obvious IllegalArgumentException goes away?

I am not sure, maybe this is the right protection but I wonder if throwing a runtime exception in a constructor is a bug or a feature and if all constructors that handle closeable objects should take care of these exceptions that are not declared. I am maybe overthinking this but we had the case in another constructor recently so I am fine keeping the protection if this is something that we do everywhere ?

@DaveCTurner DaveCTurner merged commit f9a9dcb into elastic:master Oct 21, 2019
@DaveCTurner DaveCTurner deleted the 2019-10-18-close-query-cache-on-failure branch October 21, 2019 07:43
DaveCTurner added a commit that referenced this pull request Oct 21, 2019
Today it is possible that we create the `QueryCache` and then fail to create
the owning `IndexService` and this means we do not close the `QueryCache`
again. This commit addresses that leak.

Fixes #48186
DaveCTurner added a commit that referenced this pull request Oct 21, 2019
The previous commit, 3a6fa0b introduces a
compile error that was fixed locally but not committed. This commit adds the
missing change.
DaveCTurner added a commit that referenced this pull request Oct 21, 2019
Today it is possible that we create the `QueryCache` and then fail to create
the owning `IndexService` and this means we do not close the `QueryCache`
again. This commit addresses that leak.

Fixes #48186
DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Oct 21, 2019
Today it is possible that we create the `QueryCache` and then fail to create
the owning `IndexService` and this means we do not close the `QueryCache`
again. This commit addresses that leak.

Fixes elastic#48186
DaveCTurner added a commit that referenced this pull request Oct 21, 2019
Today it is possible that we create the `QueryCache` and then fail to create
the owning `IndexService` and this means we do not close the `QueryCache`
again. This commit addresses that leak.

Fixes #48186
Backport of #48230
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed/CRUD A catch all label for issues around indexing, updating and getting a doc by id. Not search. v6.8.5 v7.5.0 v7.6.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query cache is not cleaned up in case of an index creation failure
6 participants