Chaho12 opened a new issue, #7802:
URL: https://github.com/apache/kyuubi/issues/7802

   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   
   
   ### Search before asking
   
   - [x] I have searched in the 
[issues](https://github.com/apache/kyuubi/issues?q=is%3Aissue) and found no 
similar issues.
   
   
   ### Describe the bug
   
   `SessionLimiterImpl.increment` takes a count on up to three keys in turn - 
`user:ipaddress`, then
   `user`, then `ipaddress` - and `incrLimitCount` throws as soon as one of 
them is over its limit.
   `incrLimitCount` gives back the count of the key it rejects, but nothing 
gives back the keys
   taken before it: the session is never opened, so `closeSession` never runs 
for it.
   
   So every open rejected by `kyuubi.server.limit.connections.per.ipaddress` 
keeps one count on the
   user's `user` (and `user:ipaddress`) key, and every open rejected by
   `kyuubi.server.limit.connections.per.user` keeps one on `user:ipaddress`. 
Once enough opens have
   been rejected, the user is turned away by `per.user` although they hold no 
session, until the
   server restarts - the same lockout as #7759, reached through a different 
path.
   
   This shows up wherever many users share one client address, e.g. behind a 
gateway or proxy: the
   shared address fills up, and each user who tries while it is full slowly 
loses their own quota.
   
   Steps to reproduce, with `per.user=5` and `per.ipaddress=1`:
   
   1. User `alice` opens one session from address A (address A is now full).
   2. User `bob` tries 5 times from address A - each is rejected with 
`Connection limit per
      ipaddress reached`, but `bob`'s user count goes up to 5.
   3. `bob` tries from address B, holding no session - rejected with 
`Connection limit per user
      reached (user: bob limit: 5)`.
   
   ### Affects Version(s)
   
   master/1.11.1
   
   ### Kyuubi Server Log Output
   
   ```logtalk
   org.apache.kyuubi.KyuubiSQLException: Connection limit per ipaddress reached 
(ipaddress: <ip-a> limit: 1)
   
   ... after 5 such rejections, from another address with no session open:
   
   org.apache.kyuubi.KyuubiSQLException: Connection limit per user reached 
(user: bob limit: 5)
   ```
   
   ### Kyuubi Engine Log Output
   
   ```logtalk
   > Fails before engine starts
   ```
   
   ### Kyuubi Server Configurations
   
   ```yaml
   kyuubi.server.limit.connections.per.user       5
   kyuubi.server.limit.connections.per.ipaddress  1
   ```
   
   ### Kyuubi Engine Configurations
   
   ```yaml
   > Fails before engine starts
   ```
   
   ### Additional context
   
   Fix proposal: in `SessionLimiterImpl.increment`, remember the keys taken so 
far and give them
   back when a later key is rejected, so a rejected open leaves no count behind.
   
   ### Are you willing to submit PR?
   
   - [x] Yes. I would be willing to submit a PR with guidance from the Kyuubi 
community to fix.
   - [ ] No. I cannot submit a PR at this time.
   


-- 
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