Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ abstract class AbstractSession(
@volatile private var _lastIdleTime: Long = _createTime
override def lastIdleTime: Long = _lastIdleTime

@volatile private var _closed: Boolean = false

override def getNoOperationTime: Long = {
if (lastIdleTime > 0) System.currentTimeMillis() - _lastIdleTime else 0
}
Expand Down Expand Up @@ -87,6 +89,11 @@ abstract class AbstractSession(
}

override def close(): Unit = withAcquireRelease() {
if (_closed) {
return
}
_closed = true
info(s"Mark session $handle closed")
opHandleSet.forEach { opHandle =>
try {
sessionManager.operationManager.closeOperation(opHandle)
Expand All @@ -95,8 +102,11 @@ abstract class AbstractSession(
warn(s"Error closing operation $opHandle during closing $handle for", e)
}
}
info(s"Closed all operations for session $handle")
}

override def isClosed: Boolean = _closed

protected def runOperation(operation: Operation): OperationHandle = {
try {
val opHandle = operation.getHandle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ trait Session {
def open(): Unit
def close(): Unit

def isClosed: Boolean

def getInfo(infoType: TGetInfoType): TGetInfoValue

def executeStatement(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ class KyuubiSessionImpl(
_engineSessionHandle =
engineClient.openSession(protocol, user, passwd, openEngineSessionConf)
_client = engineClient
if (isClosed) {
shouldRetry = false
throw KyuubiSQLException(s"KyuubiSession $handle has been closed")
}
logSessionInfo(s"Connected to engine [$host:$port]/[${client.engineId.getOrElse("")}]" +
s" with ${_engineSessionHandle}]")
shouldRetry = false
Expand Down Expand Up @@ -210,7 +214,7 @@ class KyuubiSessionImpl(
throw e
} finally {
attempt += 1
if (shouldRetry && engineClient != null) {
if ((isClosed || shouldRetry) && engineClient != null) {
try {
engineClient.closeSession()
} catch {
Expand Down
Loading