Chaho12 opened a new pull request, #7803:
URL: https://github.com/apache/kyuubi/pull/7803

   <!--
   Thanks for sending a pull request!
   
   Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: 
https://kyuubi.readthedocs.io/en/master/contributing/code/index.html
     2. If the PR is related to an issue in 
https://github.com/apache/kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, 
e.g., '[KYUUBI #XXXX] Your PR title ...'.
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., 
'[WIP][KYUUBI #XXXX] Your PR title ...'.
   -->
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new feature, clarify the use cases.
     2. If you fix a bug, you can clarify why it is a bug, and what versions 
are affected.
   -->
   
   `SessionLimiterImpl.increment` counts up to three keys in turn - 
`user:ipaddress`, `user`, then
   `ipaddress` - and `incrLimitCount` throws as soon as one is over its limit. 
It gives back the count
   of the key that rejects, but not the keys counted before it, and the 
rejected session is never
   opened, so `closeSession` never gives them back either.
   
   Every open rejected by `kyuubi.server.limit.connections.per.ipaddress` 
therefore keeps one count on
   the user's `user` and `user:ipaddress` keys, and every open rejected by
   `kyuubi.server.limit.connections.per.user` keeps one on `user:ipaddress`. 
After enough rejections
   the user is turned away by `per.user` while holding no session, until the 
server restarts - the
   same lockout as #7759, through a different path. It shows up wherever many 
users share one client
   address, such as behind a gateway: while the shared address is full, each 
user who tries loses
   their own quota.
   
   This patch remembers the keys counted so far in `increment` and gives them 
back when a later key
   rejects the session.
   
   Affects master and 1.11.1.
   
   close #7802
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some 
test cases that check the changes thoroughly including negative and positive 
cases if possible.
   If it was tested in a way different from regular unit tests, please clarify 
how you tested step by step, ideally copy and paste-able, so that other 
reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why 
it was difficult to add.
   -->
   
   Added a case to `SessionLimiterSuite` with `per.user=5` and 
`per.ipaddress=1`: a user rejected 10
   times by the full address keeps no count on `user` or `user:ipaddress` and 
is still let in from
   another address, and a rejection by the user limit gives back the 
`user:ipaddress` count.
   
       build/mvn test -pl kyuubi-server -am -Dtest=none \
           -DwildcardSuites=org.apache.kyuubi.session.SessionLimiterSuite
   
   Passes with the change; with the change reverted it fails on the sixth 
attempt with
   `"Connection limit per user reached (user: user002 limit: 5)" did not start 
with
   "Connection limit per ipaddress reached"`, which is the lockout described 
above.
   
   ### Was this patch assisted by generative AI tooling?
   <!--
   If generative AI tooling has assisted in authoring or reviewing this patch, 
please include
   an 'Assisted-by: ' trailer that identifies the agent and/or model.
   For example: 'Assisted-by: Claude Opus 4.7' or 'Assisted-by: 
Claude:claude-opus-4-7'.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling 
Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   
   Assisted-by: Claude Opus 5.5
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to