Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

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

avatar
New Contributor

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 4

avatar
Community Manager

@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.


Regards,

Diana Torres,
Community Moderator


Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Learn more about the Cloudera Community:

avatar
Expert Contributor

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

avatar
New Contributor

@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 

avatar
Expert Contributor

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.