clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

Provide method to get query_id from Statement object

Open drstrangelooker opened this issue 6 years ago • 3 comments

I help develop a BI tool and data platform called Looker and I am developing the dialect for ClickHouse. I need to kill a running query from a different connection.

I think I would be in good shape if I had a way of getting the query_id from the statement object after the query has been started. But the query_id is private so I have no way of using it.

If a method could be added to allow the query_id to be retrieved, it would help me greatly.

drstrangelooker avatar Oct 07 '19 18:10 drstrangelooker

@alex-krash could you take a look at this?

From my experience with a kind of similar feature in some other application working with ClickHouse, just knowing query_id is not enough. Often there's some sort of load balancing proxy in between and you'll also need to be able to bypass it to kill the query on exactly the same node where it was initially launched (for example by remembering the final hostname and making a direct connection there).

blinkov avatar Oct 07 '19 19:10 blinkov

@blinkov , I think that making query_id available is a good idea. It is generated on client side, and is available before we send request. Regarding your thoughts about balancer - solution with persisting final hostname can be inconsistent, when using TCP-level balancers, that does not expose HTTP redirect to destination. So, I propose not to do it.

alex-krash avatar Oct 09 '19 06:10 alex-krash

@alex-krash that application I mentioned works mostly via TCP-level balancers and is based on rather complex logic around SELECT hostName() and system tables. During few years in production I don't remember any major issues or inconsistencies with it. It is indeed not clear if it's worth implementing similar feature right inside JDBC driver, but at least it's something to think about for people who want to implement "Cancel" button for ClickHouse queries in their applications, like @deangelo-llooker probably does.

blinkov avatar Oct 09 '19 07:10 blinkov