cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
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!

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.