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

Fix duplicate query ID error

Open chernser opened this issue 1 year ago • 1 comments

Summary

In the JDBC driver every Statement has own request object, but it is shared among requests. If statement object is used by different threads then one thread may copy query_id set by another. Ignoring the fact that threads should not share Statements there should be a proper synchronization when working with shared request object. Current PR implements locking on request object while making copy (seal operation).

Closes:

  • https://github.com/ClickHouse/clickhouse-java/issues/1529

Checklist

Delete items not relevant to your PR:

  • [ ] Unit and integration tests covering the common scenarios were added
  • [ ] A human-readable description of the changes was provided to include in CHANGELOG

chernser avatar Jun 24 '24 20:06 chernser

I've removed busy check from java11 HttpClientConnection because it doesn't make sense. This is similar to Apache connection but has busy check for some reason. I've inspected the code of the HttpClientConnection and it looks very simple and stateless - that means mostly thread-safe.

chernser avatar Jun 25 '24 06:06 chernser