cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Thread leakage when connection cannot be established

krocodl
Contributor

During the execution of the next code we can observe a lost thread that will never end:

@Test
public void pureConnectionErrorTest() throws Exception {
try {
DriverManager.getConnection(DATABRICKS_JDBC_URL, DATABRICKS_USERNAME, DATABRICKS_PASSWORD + "!");
fail();
} catch (Exception ex) {
// it is normal
}
while(true) {
Thread.sleep(1000);
System.out.println(".");
}
}

This thread looks like the next:

"Connection evictor" #18 daemon prio=5 os_prio=31 cpu=0.10ms elapsed=7.05s tid=0x00007f9bd0925c00 nid=0x9603 waiting on condition [0x000000030ef7d000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(java.base@17.0.3/Native Method)
at com.databricks.client.jdbc42.internal.apache.http.impl.client.IdleConnectionEvictor$1.run(IdleConnectionEvictor.java:66)
at java.lang.Thread.run(java.base@17.0.3/Thread.java:833)

It is lost, because method IdleConnectionEvictor#shutdown was not called.

Root exception:

Caused by: com.databricks.client.support.exceptions.ErrorException: [Databricks][DatabricksJDBCDriver](500593) Communication link failure. Failed to connect to server. Reason: HTTP Response code: 403, Error message: Unknown.
... 85 common frames omitted
Caused by: com.databricks.client.jdbc42.internal.apache.thrift.transport.TTransportException: HTTP Response code: 403, Error message: Unknown
at com.databricks.client.hivecommon.api.TETHttpClient.handleHeaderErrorMessage(Unknown Source)

2 ACCEPTED SOLUTIONS

Accepted Solutions

krocodl
Contributor

I suspect, that you have to call 

TProtocol#getTransport().close()

 in case of catching exception inside 

HS2Client#openSession();

 In this case you have also rewrite TETHttpClient#close() in order to call ((ExtendedHttpClient)this.m_client).close(); in any cases.

After that my test started to work properly.

View solution in original post

krocodl
Contributor

This issue is reported as fixed since v2.6.34. I validated version 

2.6.36

- it works normal. Many thanks to the developers for the work done!

View solution in original post

2 REPLIES 2

krocodl
Contributor

I suspect, that you have to call 

TProtocol#getTransport().close()

 in case of catching exception inside 

HS2Client#openSession();

 In this case you have also rewrite TETHttpClient#close() in order to call ((ExtendedHttpClient)this.m_client).close(); in any cases.

After that my test started to work properly.

krocodl
Contributor

This issue is reported as fixed since v2.6.34. I validated version 

2.6.36

- it works normal. Many thanks to the developers for the work done!

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group