Chaho12 opened a new issue, #7759: URL: https://github.com/apache/kyuubi/issues/7759
### 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 `KyuubiSessionManager.openSession` takes a count from the session limiter before opening the session, and `closeSession` is the only place that gives one back. `SessionManager.openSession` calls `createSession` outside the `try` block whose `catch` calls `closeSession`, and `AbstractSession.normalizedConf` is a `val`, so a session whose conf fails validation dies inside the constructor and is never registered in `handleToSession`. `closeSession` therefore never runs for it and the count is kept for good. Once as many opens have failed as `kyuubi.server.limit.connections.per.user` allows, every further open from that user is rejected by the limiter, with no open session behind the count, until the server restarts. `kyuubi.server.limit.connections.per.ipaddress` leaks the same way. This is reachable with ordinary client configuration on a server that follows the documented `kyuubi.session.conf.restrict.list` guidance: a client that keeps sending a restricted key - for example the `spark.sql.extensions` entry in the example list of https://kyuubi.readthedocs.io/en/master/security/session_configuration.html - locks its own account out. ### Affects Version(s) master/1.11.1 ### Kyuubi Server Log Output ```logtalk org.apache.kyuubi.KyuubiSQLException: Error opening session for <user> client ip <ip>, due to spark.sql.extensions is a restrict key according to the server-side configuration, please remove it and retry if you want to proceed at org.apache.kyuubi.session.SessionManager.validateKey(SessionManager.scala:220) at org.apache.kyuubi.session.KyuubiSessionManager.openSession(KyuubiSessionManager.scala:125) ... after the limit is reached, the same client gets: org.apache.kyuubi.KyuubiSQLException: Connection limit per user reached (user: <user> limit: 20) at org.apache.kyuubi.session.SessionLimiterImpl.incrLimitCount(SessionLimiter.scala:92) at org.apache.kyuubi.session.KyuubiSessionManager.openSession(KyuubiSessionManager.scala:115) ``` ### Kyuubi Engine Log Output ```logtalk > Fails before engine starts ``` ### Kyuubi Server Configurations ```yaml kyuubi.server.limit.connections.per.user 20 kyuubi.session.conf.restrict.list spark.sql.extensions ``` ### Kyuubi Engine Configurations ```yaml > Fails before engine starts ``` ### Additional context Observed on a 3-node deployment: each node showed exactly 20 rejections with the restrict-key message, after which every open from that user failed with the connection-limit message while `kyuubi_connection_opened` stayed 0. A rolling restart was the only way to recover. ### 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]
