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

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

                Author: ASF GitHub Bot
            Created on: 22/Jul/26 09:20
            Start Date: 22/Jul/26 09:20
    Worklog Time Spent: 10m 
      Work Description: hanicz opened a new pull request, #1317:
URL: https://github.com/apache/knox/pull/1317

   [KNOX-3041](https://issues.apache.org/jira/browse/KNOX-3041) - Eliminate 
load-balancing race condition in HA dispatch
   
   ## What changes were proposed in this pull request?
   
   Replace the peek-at-rewrite + shift-after-response backend selection with an 
atomic pick-and-advance at dispatch time. The old pattern let concurrent 
requests observe the same queue head for the entire HTTP round trip, so a slow 
request would pin every concurrent request onto the same backend.
   
   - Add URLManager#getActiveURLAndAdvance (and the HaProvider passthrough), 
implemented as a synchronized poll+offer so concurrent callers see distinct 
URLs whenever more than one is configured.
   - setBackendUri now picks and rotates atomically; remove shiftActiveURL / 
shiftCallback and the after-response shift in the sync and SSE dispatchers.
   - Add updateBackendURL so a re-targeted request carries the picked backend's 
base path (HA instances may publish per-server paths, e.g. HiveServer2), 
recovering the source's base path by matching configured pool URLs.
   
   
   **Two pre-existing bugs remain**
   1. activeURL is set for the failed one after a failover for non LB-requests.
   2. Failover might go to the same backend that just failed if there are 
concurrent requests that rotate the URLs.
   
   ## How was this patch tested?
   
   - Tested locally with custom service
   - Tested locally with custom SSE service
   - Unit tests
   
   ## Integration Tests
   N/A
   
   ## UI changes
   N/A
   




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

            Worklog Id:     (was: 1031638)
    Remaining Estimate: 0h
            Time Spent: 10m

> Load Balancer backend selection synchronization issue
> -----------------------------------------------------
>
>                 Key: KNOX-3041
>                 URL: https://issues.apache.org/jira/browse/KNOX-3041
>             Project: Apache Knox
>          Issue Type: Bug
>          Components: Server
>            Reporter: Istvan Toth
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> I was trying to run a benchmark over Knox, with several Http client instances 
> started at the same time on separate threads.
> I found that every single client was directed to the same backend, which was 
> saved in the session, so instead of accessing each backend, every request was 
> directed to a single one.
> While this was a benchmark/load test tool, any non-interactive client can 
> exhibit similar behaviour, defating the point of load balancing.
> Looking at 
> org.apache.knox.gateway.ha.dispatch.ConfigurableHADispatch.executeRequestWrapper(HttpUriRequest,
>  HttpServletRequest, HttpServletResponse) 
> , I think that the sitation could be improved by calling 
> haProvider.makeNextActiveURLAvailable BEFORE the request is executed.
> It would be still racy, but the race window would be dramatically smaller, 
> running some simple local code, which should be on the microsecond scale, 
> instead of performing a full HTTP reqest, which is on on the millisecond 
> scale at best.



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

Reply via email to