[ 
https://issues.apache.org/jira/browse/KNOX-2912?focusedWorklogId=865233&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-865233
 ]

ASF GitHub Bot logged work on KNOX-2912:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 13/Jun/23 13:27
            Start Date: 13/Jun/23 13:27
    Worklog Time Spent: 10m 
      Work Description: zeroflag commented on code in PR #763:
URL: https://github.com/apache/knox/pull/763#discussion_r1228133878


##########
gateway-provider-ha/src/main/java/org/apache/knox/gateway/ha/dispatch/ConfigurableHADispatch.java:
##########
@@ -220,7 +220,7 @@ protected void executeRequest(HttpUriRequest 
outboundRequest, HttpServletRequest
     } catch ( IOException e ) {
       /* if non-idempotent requests are not allowed to failover, unless it's a 
connection error */
       if(!isConnectionError(e.getCause()) && 
isNonIdempotentAndNonIdempotentFailoverDisabled(outboundRequest)) {
-        LOG.cannotFailoverNonIdempotentRequest(outboundRequest.getMethod(), 
e.toString());
+        LOG.cannotFailoverNonIdempotentRequest(outboundRequest.getMethod(), 
e.getCause());

Review Comment:
   Thanks for the review @moresandeep. I tried it with a null cause, but it did 
not cause an NPE, it just logged out null.
   
   ```
   2023-06-13 15:16:05,205 8a432e79-6f55-4be0-8ef3-fcbe74773e19 ERROR 
knox.gateway (ConfigurableHADispatch.java:executeRequest(222)) - Request is 
non-idempotent POST, failover prevented, to allow non-idempotent requests to 
failover set failoverNonIdempotentRequestEnabled=true in HA config. Non 
connection related error: null
   ```
   
   But this shouldn't happen because we always wrap the cause into an 
IOException, so the cause shouldn't be empty.
   
   My problem with the `toString` was, that it didn't reveal the actual cause 
(which is used to make the decision whether to fail over or not).
   
   Here is how the message looked like before (using the `toString`):
   
   ```
   2023-06-12 15:09:28,865 30b4e772d8617006eca9b589eda16813 ERROR knox.gateway 
(ConfigurableHADispatch.java:executeRequest(223)) - Request is non-idempotent 
POST, failover prevented, to allow non-idempotent requests to failover set 
failoverNonIdempotentRequestEnabled=true in HA config. Non connection related 
error: java.io.IOException: Service connectivity error.
   ```
   
   Basically the error message was always the same regardless the error.
   
   From this message I can't see if the error happened because of a connection 
timeout or connection refused or any other reason.
   
   Now it looks like:
   
   ```
   2023-06-13 13:14:20,843 34dd13f0-324b-421e-b6e6-5947e0e38440 ERROR 
knox.gateway (ConfigurableHADispatch.java:executeRequest(223)) - Request is 
non-idempotent POST, failover prevented, to allow non-idempotent requests to 
failover set failoverNonIdempotentRequestEnabled=true in HA config. Non 
connection related error: javax.net.ssl.SSLException: java.net.SocketException: 
Socket closed
   ```





Issue Time Tracking
-------------------

    Worklog Id:     (was: 865233)
    Time Spent: 50m  (was: 40m)

> Don't fail over non idempotent requests unless it's a connect exception
> -----------------------------------------------------------------------
>
>                 Key: KNOX-2912
>                 URL: https://issues.apache.org/jira/browse/KNOX-2912
>             Project: Apache Knox
>          Issue Type: Task
>            Reporter: Attila Magyar
>            Assignee: Attila Magyar
>            Priority: Major
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> Currently knox tries to fail over non idempotent (POST/PUT/etc) requests. 
> Failover should only happen if the request was not yet consumed, eg.: a 
> connection related exception happened.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to