Skip to main content
hqbhoho
Silver ⭐️
March 21, 2023
Question

Why Impala JDBC close() and execute() with synchronized

I use Impala JDBC to query, I find  close() and execute() with synchronized. So if I invoke close() in other thread will wait execute() ,because if execute() is running,close() will blocked waiting for lock. So I should invoke cancal() before close() to avoid  block? 

4 replies

DianaTorres
Community Manager
Community Manager
March 21, 2023

@hqbhoho Welcome to the Cloudera Community!

To help you get the best possible solution, I have tagged our Impala experts @mszurap and @bbreak  who may be able to assist you further.

Please keep us updated on your post, and we hope you find a satisfactory solution to your query.

Translate
Regards, Diana Torres, Senior Community Moderator
bbreak
Gold ⭐️
Gold ⭐️
March 21, 2023

@hqbhoho , if the query is executing, it probably makes sense to cancel it before you try to call close.

Translate
hqbhoho
hqbhohoAuthor
Silver ⭐️
March 22, 2023

@bbreak  thanks, I will try. In my case, I wan't call close to close a statement. execute and close will call in different thread. So Why synchronized both close and execute? Now close will not work before execute 

complete 

Translate
bbreak
Gold ⭐️
Gold ⭐️
March 27, 2023

Closing the connection while the query is still executing is generally not good practice. Think of it as taking ownership for the query you've executed, sort of like turning the lights off before you leave a room. If you're going to close the session (leave the room), you need to first cancel the query that's consuming resources (turn off the lights you turned on). The normal expectation is that an executing query will have an associated active session.

Translate