Skip to content

Commit ed177fc

Browse files
cxzl25yaooqinn
authored andcommitted
[KYUUBI #2125] closeSession should avoid sending RPC after openSession fails
### _Why are the changes needed?_ #2125 Now after the `openSession` call fails, `closeSession` is called. But because there is no `_remoteSessionHandle`, the `CloseSession` RPC request fails. This does not need to send RPC and also increases the complexity of logging. ``` org.apache.kyuubi.KyuubiSQLException: Error while cleaning up the engine resources at org.apache.kyuubi.KyuubiSQLException$.apply(KyuubiSQLException.scala:69) at org.apache.kyuubi.session.KyuubiSessionImpl.close(KyuubiSessionImpl.scala:156) at org.apache.kyuubi.session.KyuubiSessionManager.openSession(KyuubiSessionManager.scala:75) at org.apache.kyuubi.service.AbstractBackendService.openSession(AbstractBackendService.scala:45) at org.apache.kyuubi.service.ThriftBinaryFrontendService.getSessionHandle(ThriftBinaryFrontendService.scala:199) ``` ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [x] Add screenshots for manual tests if appropriate - [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #2126 from cxzl25/KYUUBI-2125. Closes #2125 2e96f41 [sychen] optimize closeSession Authored-by: sychen <sychen@trip.com> Signed-off-by: Kent Yao <yao@apache.org> (cherry picked from commit 8c85480) Signed-off-by: Kent Yao <yao@apache.org>
1 parent 1a6e7cc commit ed177fc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

kyuubi-server/src/main/scala/org/apache/kyuubi/client/KyuubiSyncThriftClient.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ class KyuubiSyncThriftClient private (protocol: TProtocol)
7979
}
8080

8181
def closeSession(): Unit = {
82-
val req = new TCloseSessionReq(_remoteSessionHandle)
8382
try {
84-
val resp = withLockAcquired(CloseSession(req))
85-
ThriftUtils.verifyTStatus(resp.getStatus)
83+
if (_remoteSessionHandle != null) {
84+
val req = new TCloseSessionReq(_remoteSessionHandle)
85+
val resp = withLockAcquired(CloseSession(req))
86+
ThriftUtils.verifyTStatus(resp.getStatus)
87+
}
8688
} catch {
8789
case e: Exception =>
8890
throw KyuubiSQLException("Error while cleaning up the engine resources", e)

0 commit comments

Comments
 (0)