This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch branch-1.6
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/branch-1.6 by this push:
new 340558659 [KYUUBI #4334] [REST] Rest client should catch
`NoHttpResponse Exception` and retry
340558659 is described below
commit 3405586590cfe8adb4c08dca5385e6d3ba4e766c
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]>
(cherry picked from commit a17ccdf27a5c18b8193233c9c02c80ae5d55d08d)
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 7b93f559e..5f1641f5b 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
@@ -26,6 +26,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;
@@ -126,7 +127,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) {