<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Facing Issues with Databricks JDBC Connectivity after Idle time in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/facing-issues-with-databricks-jdbc-connectivity-after-idle-time/m-p/38473#M6008</link>
    <description>&lt;P&gt;Hello team,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using commons(&lt;SPAN&gt;commons-dbcp2)&amp;nbsp;&lt;/SPAN&gt;Datasource which supports default connection pooling in Spring Java application (rest services to fetch databricks data via JDBC template).&lt;/P&gt;&lt;P&gt;Initially all works fine and can get the data from databricks via jdbc template and already created databricks connection from connection pool.&lt;/P&gt;&lt;P&gt;Databricks JDBC url format is :&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;jdbc:databricks://dbc-f2536520-fc66.cloud.databricks.com:443/default;transportMode=http;ssl=1;httpPath=sql/protocolv1/o/7781542073893090/0329-163852-fxzadblp;AuthMech=3;UID=token;PWD=&amp;lt;PWDTOKEN&amp;gt;&lt;/DIV&gt;&lt;P&gt;The databricks jar which I am using for datasource connection is&lt;/P&gt;&lt;DIV&gt;&amp;lt;&lt;SPAN&gt;dependency&lt;/SPAN&gt;&amp;gt;&lt;BR /&gt;&amp;lt;&lt;SPAN&gt;groupId&lt;/SPAN&gt;&amp;gt;com.databricks&amp;lt;/&lt;SPAN&gt;groupId&lt;/SPAN&gt;&amp;gt;&lt;BR /&gt;&amp;lt;&lt;SPAN&gt;artifactId&lt;/SPAN&gt;&amp;gt;databricks-jdbc&amp;lt;/&lt;SPAN&gt;artifactId&lt;/SPAN&gt;&amp;gt;&lt;BR /&gt;&amp;lt;&lt;SPAN&gt;version&lt;/SPAN&gt;&amp;gt;2.6.33&amp;lt;/&lt;SPAN&gt;version&lt;/SPAN&gt;&amp;gt;&lt;BR /&gt;&amp;lt;/&lt;SPAN&gt;dependency&lt;/SPAN&gt;&amp;gt;&lt;/DIV&gt;&lt;P&gt;The issue is when I stay the running server idle for more than 20 mins, I starts getting below issue from databricks.&lt;/P&gt;&lt;P&gt;[Databricks][DatabricksJDBCDriver](500051) ERROR processing query/statement. Error Code: 0, SQL state: TStatus(statusCode:ERROR_STATUS, infoMessages:[*org.apache.hive.service.cli.HiveSQLException:Invalid SessionHandle: SessionHandle [56eea0f9-f7ee-400e-b2f6-5e9cec51c2a4]:62:61, org.apache.hive.service.cli.session.SessionManager:getSession:SessionManager.java:349, org.apache.spark.sql.hive.thriftserver.SparkSQLSessionManager:getSession:SparkSQLSessionManager.scala:179, com.databricks.sql.hive.thriftserver.thrift.ThriftHandlerUtils$:getSessionHandle:ThriftHandlerUtils.scala:55,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if anyone has faced this issue and what is the resolution for it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jul 2023 10:18:40 GMT</pubDate>
    <dc:creator>AbhiJ</dc:creator>
    <dc:date>2023-07-26T10:18:40Z</dc:date>
    <item>
      <title>Facing Issues with Databricks JDBC Connectivity after Idle time</title>
      <link>https://community.databricks.com/t5/get-started-discussions/facing-issues-with-databricks-jdbc-connectivity-after-idle-time/m-p/38473#M6008</link>
      <description>&lt;P&gt;Hello team,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using commons(&lt;SPAN&gt;commons-dbcp2)&amp;nbsp;&lt;/SPAN&gt;Datasource which supports default connection pooling in Spring Java application (rest services to fetch databricks data via JDBC template).&lt;/P&gt;&lt;P&gt;Initially all works fine and can get the data from databricks via jdbc template and already created databricks connection from connection pool.&lt;/P&gt;&lt;P&gt;Databricks JDBC url format is :&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;jdbc:databricks://dbc-f2536520-fc66.cloud.databricks.com:443/default;transportMode=http;ssl=1;httpPath=sql/protocolv1/o/7781542073893090/0329-163852-fxzadblp;AuthMech=3;UID=token;PWD=&amp;lt;PWDTOKEN&amp;gt;&lt;/DIV&gt;&lt;P&gt;The databricks jar which I am using for datasource connection is&lt;/P&gt;&lt;DIV&gt;&amp;lt;&lt;SPAN&gt;dependency&lt;/SPAN&gt;&amp;gt;&lt;BR /&gt;&amp;lt;&lt;SPAN&gt;groupId&lt;/SPAN&gt;&amp;gt;com.databricks&amp;lt;/&lt;SPAN&gt;groupId&lt;/SPAN&gt;&amp;gt;&lt;BR /&gt;&amp;lt;&lt;SPAN&gt;artifactId&lt;/SPAN&gt;&amp;gt;databricks-jdbc&amp;lt;/&lt;SPAN&gt;artifactId&lt;/SPAN&gt;&amp;gt;&lt;BR /&gt;&amp;lt;&lt;SPAN&gt;version&lt;/SPAN&gt;&amp;gt;2.6.33&amp;lt;/&lt;SPAN&gt;version&lt;/SPAN&gt;&amp;gt;&lt;BR /&gt;&amp;lt;/&lt;SPAN&gt;dependency&lt;/SPAN&gt;&amp;gt;&lt;/DIV&gt;&lt;P&gt;The issue is when I stay the running server idle for more than 20 mins, I starts getting below issue from databricks.&lt;/P&gt;&lt;P&gt;[Databricks][DatabricksJDBCDriver](500051) ERROR processing query/statement. Error Code: 0, SQL state: TStatus(statusCode:ERROR_STATUS, infoMessages:[*org.apache.hive.service.cli.HiveSQLException:Invalid SessionHandle: SessionHandle [56eea0f9-f7ee-400e-b2f6-5e9cec51c2a4]:62:61, org.apache.hive.service.cli.session.SessionManager:getSession:SessionManager.java:349, org.apache.spark.sql.hive.thriftserver.SparkSQLSessionManager:getSession:SparkSQLSessionManager.scala:179, com.databricks.sql.hive.thriftserver.thrift.ThriftHandlerUtils$:getSessionHandle:ThriftHandlerUtils.scala:55,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if anyone has faced this issue and what is the resolution for it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 10:18:40 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/facing-issues-with-databricks-jdbc-connectivity-after-idle-time/m-p/38473#M6008</guid>
      <dc:creator>AbhiJ</dc:creator>
      <dc:date>2023-07-26T10:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: Facing Issues with Databricks JDBC Connectivity after Idle time</title>
      <link>https://community.databricks.com/t5/get-started-discussions/facing-issues-with-databricks-jdbc-connectivity-after-idle-time/m-p/38541#M6010</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/9"&gt;@Retired_mod&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The links which you pasted seems doesn't works.&lt;/P&gt;&lt;P&gt;Anyways, please find my response for your suggestions.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1. Check if the session handle is valid and active. If the session has expired, a new session needs to be created.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am using commons connection pooling which creates a singleton datasource object with already created connections in advance.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please note that initially everything works fine and I am able to get the data from databricks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The issues arises after I don't do any activity after initial fetch for some 20 mins (with server running) and then again try to fetch the data from databricks via same datasource(pooled connection) which got created initially.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I was expecting the databricks JDBC connector jar should handle this error and create a new connection if the existing&amp;nbsp;connection got stale.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2. Check if there are any issues with the session manager. This can be done by checking the logs of the session manager and verifying if it is running correctly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I get's the same logs from databricks log4j logs (Driver logs tab of compute cluster section)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3. Verify if the JDBC driver is compatible with the Databricks version. If not, update the driver to a compatible version.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;I am using 12.2 LTS (includes Apache Spark 3.3.2, Scala 2.12) and since I am using maven databricks jdbc latest version (&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;version&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;2.6.33&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;version&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;), It should include support for 12.2 LTS version.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;P&gt;&lt;SPAN&gt;4. Check if there are any network connectivity issues between the client and the Databricks cluster. This can be done by running a ping test or using a network monitoring tool.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;There are no network issues as I initially mentioned, the initial fetch works fine and later after some idle time, databricks throws invalid session handle error.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also, I would like to mention if I open JDBC connection and close it for every requests, it works fine irrespective of idle time but I want's to leverage the benefit of connection pooling (already created connections) instead of creating and closing the connections for every request.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I think the error needs to be handled inside databricks connector&amp;nbsp;jar.&lt;/SPAN&gt;&lt;/P&gt;&lt;SPAN class=""&gt;&lt;BR /&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 27 Jul 2023 06:44:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/facing-issues-with-databricks-jdbc-connectivity-after-idle-time/m-p/38541#M6010</guid>
      <dc:creator>AbhiJ</dc:creator>
      <dc:date>2023-07-27T06:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Facing Issues with Databricks JDBC Connectivity after Idle time</title>
      <link>https://community.databricks.com/t5/get-started-discussions/facing-issues-with-databricks-jdbc-connectivity-after-idle-time/m-p/38555#M6011</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/84153"&gt;@AbhiJ&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Looking at the error it appears the&amp;nbsp;&lt;SPAN&gt;session is invalid/expired.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The error usually occurs when the jdbc/odbc client re-accesses the cluster with the same session id after the idle session timeout threshold. Ideally restarting the client could be a workaround. Also you can set the following property into the Spark Config of the cluster.```spark.hadoop.hive.server2.idle.session.timeout```&lt;BR /&gt;The default value is 900000 - 15minutes (and you mentioned it happens after 20 min)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Restarting the client will help.&lt;/P&gt;&lt;P&gt;Please let me know if that helps.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2023 09:49:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/facing-issues-with-databricks-jdbc-connectivity-after-idle-time/m-p/38555#M6011</guid>
      <dc:creator>NandiniN</dc:creator>
      <dc:date>2023-07-27T09:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: Facing Issues with Databricks JDBC Connectivity after Idle time</title>
      <link>https://community.databricks.com/t5/get-started-discussions/facing-issues-with-databricks-jdbc-connectivity-after-idle-time/m-p/49355#M6012</link>
      <description>&lt;P&gt;I am seeing the same issue with hikari. When a pooled connection is created then the databricks cluster is terminated (or restarted), the HikariDataSource retains a stale session handle.&lt;BR /&gt;&lt;BR /&gt;Why does connection.isValid() returns true then executing any query on the same connection will fail with invalid sessionHandle. I was expecting the connection.isValid() to return false in this case.&lt;/P&gt;&lt;P&gt;To reproduce:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a HikariDataSource referencing a databricks cluster.&lt;/LI&gt;&lt;LI&gt;Terminate the databricks cluster.&lt;/LI&gt;&lt;LI&gt;get a connection from the datasource like HikariDataSource.getConnection()&lt;/LI&gt;&lt;LI&gt;connection.isValid(1) return true.&lt;/LI&gt;&lt;LI&gt;connection.executeQuery("SELECT 1"), this will block until the cluster is restarted then fail with&amp;nbsp;java.sql.SQLException: [Databricks][JDBCDriver](500051) ERROR processing query/statement. Error Code: 0, SQL state: 08000, Query: SELECT 1, Error message from Server: Invalid SessionHandle.&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Tue, 17 Oct 2023 07:47:34 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/facing-issues-with-databricks-jdbc-connectivity-after-idle-time/m-p/49355#M6012</guid>
      <dc:creator>ash42</dc:creator>
      <dc:date>2023-10-17T07:47:34Z</dc:date>
    </item>
  </channel>
</rss>

