From ceb665ab67dbe01a227e088ae2b49e1005ef4e91 Mon Sep 17 00:00:00 2001 From: "Wang, Fei" Date: Sun, 18 Aug 2024 22:25:52 -0700 Subject: [PATCH] [KYUUBI #6627] Using concurrent collections for session operation handle set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # :mag: Description ## Issue References ๐Ÿ”— As mentioned in https://github.com/apache/kyuubi/pull/6626, the operation never idle because of periodical get operation status, but in my opinion, the operations should be closed after session closed, but it did not. Currently, for session operation handles set, it does not use concurrent collections, I wonder there is concurrent update issue. ## 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: - [x] 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 Not needed. --- # Checklist ๐Ÿ“ - [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html) **Be nice. Be informative.** Closes #6627 from turboFei/operation_set. Closes #6627 2b80c25e1 [Wang, Fei] revert 57e4dbfa2 [Wang, Fei] using concurrent bbd9ecf6a [Wang, Fei] use concurrent hash map Authored-by: Wang, Fei Signed-off-by: Wang, Fei (cherry picked from commit 9a82eb5c12bb455dec8ce82bc437a32363af5ca5) Signed-off-by: Wang, Fei --- .../scala/org/apache/kyuubi/session/AbstractSession.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kyuubi-common/src/main/scala/org/apache/kyuubi/session/AbstractSession.scala b/kyuubi-common/src/main/scala/org/apache/kyuubi/session/AbstractSession.scala index 2dfbe510f..14e59078f 100644 --- a/kyuubi-common/src/main/scala/org/apache/kyuubi/session/AbstractSession.scala +++ b/kyuubi-common/src/main/scala/org/apache/kyuubi/session/AbstractSession.scala @@ -17,6 +17,8 @@ package org.apache.kyuubi.session +import java.util.concurrent.ConcurrentHashMap + import scala.collection.JavaConverters._ import org.apache.kyuubi.{KyuubiSQLException, Logging} @@ -59,7 +61,7 @@ abstract class AbstractSession( override lazy val name: Option[String] = normalizedConf.get(SESSION_NAME.key) - final private val opHandleSet = new java.util.HashSet[OperationHandle] + final private val opHandleSet = ConcurrentHashMap.newKeySet[OperationHandle]() private def acquire(userAccess: Boolean): Unit = synchronized { if (userAccess) {