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

Client retries on request failure #356

Closed
TimQuist opened this issue Jul 20, 2022 · 6 comments
Closed

Client retries on request failure #356

TimQuist opened this issue Jul 20, 2022 · 6 comments
Labels
Category: Question Not an issue but a question. May lead to enhancing docs

Comments

@TimQuist
Copy link

TimQuist commented Jul 20, 2022

Description

Hi,

I am wondering if there are any plans for the new client to support the retrying of requests on failure?

I noticed when searching for this that some of the other clients seem to have this functionality:

For the previous RestHighLevelClient I have built my own retry mechanism and I am wondering if I should do the same for the new client?

One of the 'issues' I have run into when looking into implementing this mechanism myself was the fact that the client only throws a generic ElasticsearchException with ErrorResponse. Making the error handling a bit annoying to work with since most Java retry libraries depend on usage of exceptions types to determine if you want to conditionally retry a request or not.

An option would be to re-create and throw exceptions based on the ErrorResponse for the retry-able errors, or just implement the retry system myself completely without a library. But I first want to check in here before I go down that route.

I'd be willing to contribute, even though I'd have to get familiar with the codebase first.

Thanks in advance!

@Enerccio
Copy link

I would wrap Low Level Client in an retriable adapter, using spring-retry.

@TimQuist
Copy link
Author

I would wrap Low Level Client in an retriable adapter, using spring-retry.

Thanks for the suggestion, I see the Low Level Client indeed has more in place for retrying.

@nithril
Copy link

nithril commented Nov 6, 2022

It looks the rest client is still using the httpclient 4 that is not supporting retry for the async client :/

@swallez
Copy link
Member

swallez commented Nov 7, 2022

@TimQuist you will get an ElasticsearchException only if the http request was successful at the http level and Elasticsearch returned an error. All other network-level errors are reported as IOException or one of its subclasses, and you should be able check their actual type.

The Low Level Client also does retry when configured when several nodes: on network failure, it will retry up to the number of nodes.

@nithril the Low Level Client has stayed on httpclient 4 for backwards compatibility reasons. We're considering writing a new implementation of transport based on httpclient 5 that would also allow removing the dependency to the Low Level Client. It's not there yet though.

@smandyaj
Copy link

@swallez i had a quick question : What is the case when a single document fails to deserialize for an operation like
searchRs = esClient.search(searchRq, IKnowTheObject.class);
when it tries to fetch max(10000) documents ?

And
if (ex.getCause() instanceof JsonpMappingException || ex.getCause() instanceof JsonParsingException)
is this correct way to check for such exceptions ?

@l-trotta l-trotta added the Category: Question Not an issue but a question. May lead to enhancing docs label Feb 21, 2024
@l-trotta
Copy link
Contributor

I'm closing this since we're tracking the effort to update the transport layer somewhere else, if anyone have further questions please consider writing on our discuss forum :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Question Not an issue but a question. May lead to enhancing docs
Projects
None yet
Development

No branches or pull requests

6 participants