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

Cancel statement don’t work due to “Session is locked by a concurrent client” (0.3.2-patch11)

Open Veirisa opened this issue 3 years ago • 1 comments

Hi!

I'm unable to cancel a statement using the cancel() method if session_id is set.

I had the same problem with the driver v0.3.1, however, there it was possible to set the SESSION_ID to null for the ru.yandex.clickhouse.ClickHouseStatementImpl statement before cancelling with ru.yandex.clickhouse.ConfigurableApi#addDbParam.

With a new driver, a similar approach with the com.clickhouse.jdbc.internal.ClickHouseStatementImpl statement does not help. I tried to remove session_id from CUSTOM_PARAMS using com.clickhouse.client.ClickHouseRequest#option, however, this is not enough.

I need your help. Tell me, please, how can I reset the session_id in the driver v0.3.2? Or is there another way to make cancel() work?

Veirisa avatar Aug 05 '22 11:08 Veirisa

Sorry it's a bug introduced in 0.3.2-patch10. The session_id defined in connection string is re-used for query cancellation, which does not work(because ClickHouse can only execute one query at a time for each session). I don't have a good workaround for this, but you must use patch11, you may consider remove session_id from connection string and manage session manually using unwrapped statement(e.g. statement.unwrap(ClickHouseRequest.class).session(...).query(...).execute()).

zhicwu avatar Aug 06 '22 02:08 zhicwu