You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ul...@apache.org on 2023/02/06 03:12:12 UTC

[kyuubi] branch master updated: [KYUUBI #4241] Only force close engine ref when open session failed

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

ulyssesyou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/master by this push:
     new 8760eeef0 [KYUUBI #4241] Only force close engine ref when open session failed
8760eeef0 is described below

commit 8760eeef0eb1fba98db1b892510d89285b4f1727
Author: ulysses-you <ul...@gmail.com>
AuthorDate: Mon Feb 6 11:12:00 2023 +0800

    [KYUUBI #4241] Only force close engine ref when open session failed
    
    ### _Why are the changes needed?_
    
    We do not need force close engine builder and application if open session succeded. The engine itself will shutdown in connection level.
    
    This pr tries to fix regression of https://github.com/apache/kyuubi/pull/2482
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [ ] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request
    
    Closes #4241 from ulysses-you/skip-close.
    
    Closes #4241
    
    0b280411 [ulysses-you] style
    16369123 [ulysses-you] Only force close engine ref when open session failed
    
    Authored-by: ulysses-you <ul...@gmail.com>
    Signed-off-by: ulyssesyou <ul...@apache.org>
---
 .../src/main/scala/org/apache/kyuubi/session/KyuubiSessionImpl.scala | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionImpl.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionImpl.scala
index 536034b9c..ce94b0275 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionImpl.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionImpl.scala
@@ -105,6 +105,8 @@ class KyuubiSessionImpl(
 
   private var _engineSessionHandle: SessionHandle = _
 
+  private var openSessionError: Option[Throwable] = None
+
   override def open(): Unit = handleSessionException {
     traceMetricsOnOpen()
 
@@ -170,6 +172,7 @@ class KyuubiSessionImpl(
                 s"Opening engine [${engine.defaultEngineName} $host:$port]" +
                   s" for $user session failed",
                 e)
+              openSessionError = Some(e)
               throw e
           } finally {
             attempt += 1
@@ -247,7 +250,7 @@ class KyuubiSessionImpl(
     try {
       if (_client != null) _client.closeSession()
     } finally {
-      if (engine != null) engine.close()
+      openSessionError.foreach { _ => if (engine != null) engine.close() }
       sessionEvent.endTime = System.currentTimeMillis()
       EventBus.post(sessionEvent)
       traceMetricsOnClose()