You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/03/25 08:57:42 UTC

[GitHub] [incubator-kyuubi] turboFei commented on a change in pull request #2122: [KYUUBI #2102] Support to retry the internal thrift request call and add engine liveness probe to enable fast fail before retry

turboFei commented on a change in pull request #2122:
URL: https://github.com/apache/incubator-kyuubi/pull/2122#discussion_r835071021



##########
File path: kyuubi-server/src/main/scala/org/apache/kyuubi/client/KyuubiSyncThriftClient.scala
##########
@@ -69,27 +140,49 @@ class KyuubiSyncThriftClient private (protocol: TProtocol)
     req.setUsername(user)
     req.setPassword(password)
     req.setConfiguration(configs.asJava)
-    val resp = withLockAcquired(OpenSession(req))
+    val resp = withRetryingRequest(OpenSession(req), "OpenSession")
     ThriftUtils.verifyTStatus(resp.getStatus)
     _remoteSessionHandle = resp.getSessionHandle
     _engineId = Option(resp.getConfiguration)
       .filter(_.containsKey("kyuubi.engine.id"))
       .map(_.get("kyuubi.engine.id"))
+
+    engineAliveProbeClient.foreach { aliveProbeClient =>
+      Utils.tryLogNonFatalError {
+        val resp = aliveProbeClient.OpenSession(req)
+        ThriftUtils.verifyTStatus(resp.getStatus)
+        _aliveProbeSessionHandle = resp.getSessionHandle
+        startEngineAliveProbe()
+      }
+    }
+
     SessionHandle(_remoteSessionHandle, protocol)
   }
 
   def closeSession(): Unit = {
     try {
       if (_remoteSessionHandle != null) {
         val req = new TCloseSessionReq(_remoteSessionHandle)
-        val resp = withLockAcquired(CloseSession(req))
+        val resp = withRetryingRequest(CloseSession(req), "CloseSession")
         ThriftUtils.verifyTStatus(resp.getStatus)
       }
     } catch {
       case e: Exception =>
         throw KyuubiSQLException("Error while cleaning up the engine resources", e)
     } finally {
-      if (protocol.getTransport.isOpen) protocol.getTransport.close()
+      Seq(protocol).union(engineAliveProbeProtocol.toSeq).foreach { tProtocol =>
+        if (tProtocol.getTransport.isOpen) tProtocol.getTransport.close()
+      }
+      Option(engineAliveThreadPool).foreach(_.shutdown())
+      if (_aliveProbeSessionHandle != null && !remoteEngineBroken) {
+        engineAliveProbeClient.foreach { client =>
+          Utils.tryLogNonFatalError {
+            val req = new TCloseSessionReq(_aliveProbeSessionHandle)
+            val resp = client.CloseSession(req)

Review comment:
       thanks




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org