This is an automated email from the ASF dual-hosted git repository.

feiwang pushed a commit to branch branch-1.8
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/branch-1.8 by this push:
     new dd4117755 [KYUUBI #2503][FOLLOWUP] Catch all exceptions for sessions 
timeout check task
dd4117755 is described below

commit dd41177557c3b2c90eeaf3dff39109ec7c4b9c7d
Author: fwang12 <[email protected]>
AuthorDate: Mon Nov 20 11:01:05 2023 +0800

    [KYUUBI #2503][FOLLOWUP] Catch all exceptions for sessions timeout check 
task
    
    # :mag: Description
    #2503  followup
    
    1. log some message when executing timeout check task
    2. catch all exceptions when checking sessions timeout
    BTW: for `logSessionCountInfo`,  log the session class simple name to 
provide more insights, such as `KyuubiSessionImpl` or `KyuubiBatchSession`.
    ## Issue References ๐Ÿ”—
    
    This pull request fixes #
    
    ## Describe Your Solution ๐Ÿ”ง
    
    Please include a summary of the change and which issue is fixed. Please 
also include relevant motivation and context. List any dependencies that are 
required for this change.
    
    ## Types of changes :bookmark:
    
    - [ ] Bugfix (non-breaking change which fixes an issue)
    - [ ] New feature (non-breaking change which adds functionality)
    - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
    
    ## Test Plan ๐Ÿงช
    
    #### Behavior Without This Pull Request :coffin:
    
    #### Behavior With This Pull Request :tada:
    
    #### Related Unit Tests
    
    ---
    
    # Checklists
    ## ๐Ÿ“ Author Self Checklist
    
    - [ ] My code follows the [style 
guidelines](https://kyuubi.readthedocs.io/en/master/contributing/code/style.html)
 of this project
    - [ ] I have performed a self-review
    - [ ] I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] My changes generate no new warnings
    - [ ] I have added tests that prove my fix is effective or that my feature 
works
    - [ ] New and existing unit tests pass locally with my changes
    - [ ] This patch was not authored or co-authored using [Generative 
Tooling](https://www.apache.org/legal/generative-tooling.html)
    
    ## ๐Ÿ“ Committer Pre-Merge Checklist
    
    - [ ] Pull request title is okay.
    - [ ] No license issues.
    - [ ] Milestone correctly set?
    - [ ] Test coverage is ok
    - [ ] Assignees are selected.
    - [ ] Minimum number of approvals
    - [ ] No changes are requested
    
    **Be nice. Be informative.**
    
    Closes #5727 from turboFei/catch_all_exception.
    
    Closes #2503
    
    d726a8470 [fwang12] catch all
    
    Authored-by: fwang12 <[email protected]>
    Signed-off-by: fwang12 <[email protected]>
    (cherry picked from commit 37641f3b6b4959b95bb1f49abb7f7a8bb137a933)
    Signed-off-by: fwang12 <[email protected]>
---
 .../org/apache/kyuubi/session/SessionManager.scala  | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git 
a/kyuubi-common/src/main/scala/org/apache/kyuubi/session/SessionManager.scala 
b/kyuubi-common/src/main/scala/org/apache/kyuubi/session/SessionManager.scala
index a83335102..4a3d25689 100644
--- 
a/kyuubi-common/src/main/scala/org/apache/kyuubi/session/SessionManager.scala
+++ 
b/kyuubi-common/src/main/scala/org/apache/kyuubi/session/SessionManager.scala
@@ -90,7 +90,7 @@ abstract class SessionManager(name: String) extends 
CompositeService(name) {
       conf: Map[String, String]): Session
 
   protected def logSessionCountInfo(session: Session, action: String): Unit = {
-    info(s"${session.user}'s session with" +
+    info(s"${session.user}'s ${session.getClass.getSimpleName} with" +
       s" ${session.handle}${session.name.map("/" + _).getOrElse("")} is 
$action," +
       s" current opening sessions $getOpenSessionCount")
   }
@@ -303,20 +303,21 @@ abstract class SessionManager(name: String) extends 
CompositeService(name) {
 
     val checkTask = new Runnable {
       override def run(): Unit = {
+        info(s"Checking sessions timeout, current count: $getOpenSessionCount")
         val current = System.currentTimeMillis
         if (!shutdown) {
           for (session <- handleToSession.values().asScala) {
-            if (session.lastAccessTime + session.sessionIdleTimeoutThreshold 
<= current &&
-              session.getNoOperationTime > 
session.sessionIdleTimeoutThreshold) {
-              info(s"Closing session ${session.handle.identifier} that has 
been idle for more" +
-                s" than ${session.sessionIdleTimeoutThreshold} ms")
-              try {
+            try {
+              if (session.lastAccessTime + session.sessionIdleTimeoutThreshold 
<= current &&
+                session.getNoOperationTime > 
session.sessionIdleTimeoutThreshold) {
+                info(s"Closing session ${session.handle.identifier} that has 
been idle for more" +
+                  s" than ${session.sessionIdleTimeoutThreshold} ms")
                 closeSession(session.handle)
-              } catch {
-                case NonFatal(e) => warn(s"Error closing idle session 
${session.handle}", e)
+              } else {
+                session.closeExpiredOperations()
               }
-            } else {
-              session.closeExpiredOperations()
+            } catch {
+              case NonFatal(e) => warn(s"Error checking session 
${session.handle} timeout", e)
             }
           }
         }

Reply via email to