This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new a17ccdf27 [KYUUBI #4334] [REST] Rest client should catch
`NoHttpResponse Exception` and retry
a17ccdf27 is described below
commit a17ccdf27a5c18b8193233c9c02c80ae5d55d08d
Author: zwangsheng <[email protected]>
AuthorDate: Wed Feb 15 05:30:04 2023 +0000
[KYUUBI #4334] [REST] Rest client should catch `NoHttpResponse Exception`
and retry
### _Why are the changes needed?_
[NoHttpResponseException](https://hc.apache.org/httpclient-legacy/exception-handling.html)
> In some circumstances, usually when under heavy load, the web server may
be able to receive requests but unable to process them. A lack of sufficient
resources like worker threads is a good example. This may cause the server to
drop the connection to the client without giving any response. HttpClient
throws NoHttpResponseException when it encounters such a condition. In most
cases it is safe to retry a method that failed with NoHttpResponseException.
In case of Kyuubi Server is overloaded and does not have enough resources
to allocate threads to handle the corresponding request, the request will be
dropped and no response will be returned, Kyuubi Rest Client should catch this
exception and retry.
### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including
negative and positive cases if possible
- [ ] Add screenshots for manual tests if appropriate
- [ ] [Run
test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests)
locally before make a pull request
Closes #4334 from zwangsheng/rest_client/retry_with_no_http_response.
Closes #4334
d526e4ab [zwangsheng] Remove Unrelated Code
708f2496 [zwangsheng] [REST] Retry should catch NoHttpResponse Exception
and retry
Authored-by: zwangsheng <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
---
.../src/main/java/org/apache/kyuubi/client/RestClient.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git
a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/RestClient.java
b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/RestClient.java
index fa3544726..20e57b963 100644
--- a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/RestClient.java
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/RestClient.java
@@ -27,6 +27,7 @@ import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHeaders;
+import org.apache.http.NoHttpResponseException;
import org.apache.http.client.HttpResponseException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpUriRequest;
@@ -164,7 +165,7 @@ public class RestClient implements IRestClient {
response = httpclient.execute(httpRequest, responseHandler);
LOG.debug("Response: {}", response);
- } catch (ConnectException | ConnectTimeoutException e) {
+ } catch (ConnectException | ConnectTimeoutException |
NoHttpResponseException e) {
// net exception can be retried by connecting to other Kyuubi server
throw new RetryableKyuubiRestException("Api request failed for " +
uri.toString(), e);
} catch (KyuubiRestException rethrow) {