[
https://issues.apache.org/jira/browse/KNOX-3381?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Tamás Hanicz updated KNOX-3381:
-------------------------------
Description:
HADispatch fails over on IOExceptions thrown while writing the response, not
just on connection failures
ConfigurableHADispatch.executeRequest(...) wraps both the backend call and the
response-writing in a single try/catch and triggers failover on any IOException:
{code:java}
try {
inboundResponse = executeOutboundRequest(outboundRequest);
writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse,
inboundResponse); // stream/rewrite body to client
} catch (IOException e) {
if (!isConnectionError(e.getCause()) &&
isNonIdempotentAndNonIdempotentFailoverDisabled(outboundRequest)) {
...
throw e;
} else {
failoverRequest(outboundRequest, inboundRequest, outboundResponse,
inboundResponse, e);
}
}{code}
Failover is only meant to occur when Knox cannot get a response from a backend
(connection-level errors — UnknownHostException, NoRouteToHostException,
SocketException, ConnectTimeoutException). However, because
writeOutboundResponse(...) is inside the same try block, an IOException raised
after a response has already been received — e.g. while streaming or rewriting
the response body — also lands in the catch and triggers failover.
was:
HADispatch fails over on IOExceptions thrown while writing the response, not
just on connection failures
ConfigurableHADispatch.executeRequest(...) wraps both the backend call and the
response-writing in a single try/catch and triggers failover on any IOException:
{code:java}
try {
inboundResponse = executeOutboundRequest(outboundRequest);
writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse,
inboundResponse); // stream/rewrite body to client
} catch (IOException e) {
if (!isRelevantConnectionError(e.getCause()) &&
isNonIdempotentAndNonIdempotentFailoverDisabled(outboundRequest)) {
...
throw e;
} else {
failoverRequest(outboundRequest, inboundRequest, outboundResponse,
inboundResponse, e);
}
}{code}
Failover is only meant to occur when Knox cannot get a response from a backend
(connection-level errors — UnknownHostException, NoRouteToHostException,
SocketException, ConnectTimeoutException). However, because
writeOutboundResponse(...) is inside the same try block, an IOException raised
after a response has already been received — e.g. while streaming or rewriting
the response body — also lands in the catch and triggers failover.
> HADispatch retries on IOException during writeOutboundResponse
> --------------------------------------------------------------
>
> Key: KNOX-3381
> URL: https://issues.apache.org/jira/browse/KNOX-3381
> Project: Apache Knox
> Issue Type: Bug
> Components: Server
> Affects Versions: 2.1.0
> Reporter: Tamás Hanicz
> Assignee: Tamás Hanicz
> Priority: Major
>
> HADispatch fails over on IOExceptions thrown while writing the response, not
> just on connection failures
> ConfigurableHADispatch.executeRequest(...) wraps both the backend call and
> the response-writing in a single try/catch and triggers failover on any
> IOException:
> {code:java}
> try {
> inboundResponse = executeOutboundRequest(outboundRequest);
> writeOutboundResponse(outboundRequest, inboundRequest, outboundResponse,
> inboundResponse); // stream/rewrite body to client
> } catch (IOException e) {
> if (!isConnectionError(e.getCause()) &&
> isNonIdempotentAndNonIdempotentFailoverDisabled(outboundRequest)) {
> ...
> throw e;
> } else {
> failoverRequest(outboundRequest, inboundRequest, outboundResponse,
> inboundResponse, e);
> }
> }{code}
>
> Failover is only meant to occur when Knox cannot get a response from a
> backend (connection-level errors — UnknownHostException,
> NoRouteToHostException, SocketException, ConnectTimeoutException). However,
> because writeOutboundResponse(...) is inside the same try block, an
> IOException raised after a response has already been received — e.g. while
> streaming or rewriting the response body — also lands in the catch and
> triggers failover.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)