You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2025/04/24 06:14:41 UTC

(kyuubi) branch branch-1.9 updated: [KYUUBI #7035] Close the operation by operation manager to prevent operation leak

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

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


The following commit(s) were added to refs/heads/branch-1.9 by this push:
     new d18147d8bd [KYUUBI #7035] Close the operation by operation manager to prevent operation leak
d18147d8bd is described below

commit d18147d8bd25bc6a57e4d31947cc6860092a47b7
Author: Wang, Fei <fw...@ebay.com>
AuthorDate: Thu Apr 24 14:14:07 2025 +0800

    [KYUUBI #7035] Close the operation by operation manager to prevent operation leak
    
    ### Why are the changes needed?
    
    To fix the operation leak if the session init timeout.
    
    1. the operationHandle has not been added into session `opHandleSet` (super.runOperation).
    2. The `operation.close()` only close the operation, but it does not remove it from `handleToOperation` map.
    3. the session close would not remove the opHandle from `handleToOperation` as it has not been added into session `opHandleSet`
    
    So here we can resolve the operation leak by invoking `operationManager.closeOperation` to remove the operation handle and close session.
    https://github.com/apache/kyuubi/blob/cc68cb4c852dccd920ba53a4d853aa407ff83faa/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionImpl.scala#L235-L246
    
    https://github.com/apache/kyuubi/blob/cc68cb4c852dccd920ba53a4d853aa407ff83faa/kyuubi-common/src/main/scala/org/apache/kyuubi/session/AbstractSession.scala#L100-L103
    
    https://github.com/apache/kyuubi/blob/cc68cb4c852dccd920ba53a4d853aa407ff83faa/kyuubi-common/src/main/scala/org/apache/kyuubi/operation/OperationManager.scala#L127-L130
    
    https://github.com/apache/kyuubi/blob/cc68cb4c852dccd920ba53a4d853aa407ff83faa/kyuubi-common/src/main/scala/org/apache/kyuubi/session/AbstractSession.scala#L89-L92
    
    FYI: the operation was added into `handleToOperation` during new operation.
    https://github.com/apache/kyuubi/blob/cc68cb4c852dccd920ba53a4d853aa407ff83faa/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/KyuubiOperationManager.scala#L56-L64
    
    ### How was this patch tested?
    
    Minor change.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #7035 from turboFei/remove_op.
    
    Closes #7035
    
    3c376833a [Wang, Fei] close by op mgr
    
    Authored-by: Wang, Fei <fw...@ebay.com>
    Signed-off-by: Cheng Pan <ch...@apache.org>
    (cherry picked from commit ba854d3c99044835ce1702420c27a78e466ee4dd)
    Signed-off-by: Cheng Pan <ch...@apache.org>
---
 .../src/main/scala/org/apache/kyuubi/session/KyuubiSessionImpl.scala    | 2 +-
 1 file changed, 1 insertion(+), 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 ddb149c74b..1d2ed2b27f 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
@@ -234,7 +234,7 @@ class KyuubiSessionImpl(
         waitForEngineLaunched()
       } catch {
         case t: Throwable =>
-          operation.close()
+          sessionManager.operationManager.closeOperation(operation.getHandle)
           throw t
       }
       sessionEvent.totalOperations += 1