Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClickHouse QueryID Issue #870

Closed
ltl0814 opened this issue Mar 15, 2022 · 8 comments · Fixed by #1008
Closed

ClickHouse QueryID Issue #870

ltl0814 opened this issue Mar 15, 2022 · 8 comments · Fixed by #1008

Comments

@ltl0814
Copy link

ltl0814 commented Mar 15, 2022

Hi , I have a scenario here , we need to get query ID before CH return result , because user don't know this query executed quickly or not , so we injected query ID by modifying the bytecode to override your queryID ,so that we can kill this query by accurate queryID, but these days we upgrade CH to 0.3.2 ,we found that you have changed this code by this way(below image) , and this is a bit tricky to override queryID again. so could you please advise this for us ? and I think modify bytecode is not a good way to inject query ID....
image

@zhicwu
Copy link
Contributor

zhicwu commented Mar 15, 2022

we need to get query ID before CH return result

Perhaps you can call Statement.cancel() so that you don't have to know the query ID and kill the query manually?

@ltl0814
Copy link
Author

ltl0814 commented Mar 15, 2022

emm... we don't use native jdbc(mybatis instead) , so it will be a little trouble to get statement . I mean that do we can find some ways to use my query ID not yours or give me some method to get your queryID so that I can kill query as I want ? : )

@zhicwu
Copy link
Contributor

zhicwu commented Mar 15, 2022

I see. Just did a quick search and it seems mybatis still does not support cancel.

Anyway, I think we need to enhance the driver to expose methods for setting/getting query id. Before that, I can only think of AOP to replace query id passed to Clickhouse request.query(sql, queryId).

@ltl0814
Copy link
Author

ltl0814 commented Mar 15, 2022

good idea, thank you so much : )

@zhicwu
Copy link
Contributor

zhicwu commented Mar 15, 2022

I think there are a few issues requesting an interceptor and the ability to customize query id etc., I'll enhance the driver to expose an interface for this.

@zhicwu zhicwu added this to the 0.3.2-patch8 milestone Mar 31, 2022
@zhicwu zhicwu modified the milestones: 0.3.2-patch8, 0.3.3 release Apr 17, 2022
@zhicwu zhicwu modified the milestones: 0.3.3 release, 0.3.2-patch11 Jul 15, 2022
@zhicwu zhicwu linked a pull request Jul 28, 2022 that will close this issue
@zhicwu
Copy link
Contributor

zhicwu commented Jul 28, 2022

Starting from 0.3.2-patch11, you should be able to customize query ID and session ID by implementing ClickHouseRequestManager.

https://github.com/ClickHouse/clickhouse-jdbc/blob/27f8951cdc380bf1799f76efc21fc377fc6d5981/clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseRequestManager.java#L16-L17

@lelewolf
Copy link

@ltl0814 Hello, I have a requirement similar to yours. I would like to ask how you use the query ID to cancel a query, and how effective it is in a distributed ClickHouse setup?

@ltl0814
Copy link
Author

ltl0814 commented Oct 29, 2024

@ltl0814 Hello, I have a requirement similar to yours. I would like to ask how you use the query ID to cancel a query, and how effective it is in a distributed ClickHouse setup?

sql : kill query where query_id = xxx on cluster xxx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants