You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Initial problem is that JDBC driver uses session_id for all queries even control ones like in cancel() method. If session is set then cancel() causes server error SESSION_IS_LOCKED error. Correct way is to remove session settings from KILL query.
Main changes in this PR are:
new method clearSession() in QuerySettings and other operations. This method holds all session reset logic and removes session related settings like id, check, timeout. Timezone session is not removed because it can be used without session ID and used to set particular timezone for request.
fix in StatementImpl.cancel() that clones local settings and clear session. Then settings are used for KILL query.
Low Risk
Targeted cancel-path change with new session-clear API and regression tests; no auth or data-path changes beyond control queries.
Overview
Fixes jdbc-v2Statement.cancel() when the statement uses a ClickHouse session (session_id / clickhouse_setting_session_id): the internal KILL QUERY no longer inherits session settings, avoiding server error SESSION_IS_LOCKED (“Session is locked by a concurrent client”).
client-v2 adds clearSession() on CommonSettings and fluent wrappers on QuerySettings, InsertSettings, and CommandSettings. It clears session_id, session_check, and session_timeout only; session_timezone is left intact so timezone can still apply without a session.
StatementImpl.cancel() merges statement-local settings into a copy and calls clearSession() before issuing KILL QUERY (including ON CLUSTER when configured).
Unit tests cover clearSession() behavior; integration tests cancel long-running SELECT and INSERT inside a session. CHANGELOG documents the fix under 0.10.0.
Reviewed by Cursor Bugbot for commit df1a530. Bugbot is set up for automated code reviews on this repo. Configure here.
Repository collaborators can run the JMH benchmark suite against this PR by commenting:
/benchmark
Optional regression threshold override (Δ% on Time or Alloc/op; defaults to 10%):
/benchmark threshold=15
Only one benchmark run per PR is active at a time — issuing a new /benchmark comment cancels the previous run. After the run finishes a separate comment will be posted comparing it against the latest scheduled run on main; the PR check fails if any benchmark regresses by more than the threshold.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Initial problem is that JDBC driver uses
session_idfor all queries even control ones like incancel()method. If session is set thencancel()causes server errorSESSION_IS_LOCKEDerror. Correct way is to remove session settings fromKILLquery.Main changes in this PR are:
clearSession()in QuerySettings and other operations. This method holds all session reset logic and removes session related settings like id, check, timeout. Timezone session is not removed because it can be used without session ID and used to set particular timezone for request.StatementImpl.cancel()that clones local settings and clear session. Then settings are used forKILLquery.Closes #2690
Checklist
Delete items not relevant to your PR:
Note
Low Risk
Targeted cancel-path change with new session-clear API and regression tests; no auth or data-path changes beyond control queries.
Overview
Fixes jdbc-v2
Statement.cancel()when the statement uses a ClickHouse session (session_id/clickhouse_setting_session_id): the internalKILL QUERYno longer inherits session settings, avoiding server error SESSION_IS_LOCKED (“Session is locked by a concurrent client”).client-v2 adds
clearSession()onCommonSettingsand fluent wrappers onQuerySettings,InsertSettings, andCommandSettings. It clearssession_id,session_check, andsession_timeoutonly;session_timezoneis left intact so timezone can still apply without a session.StatementImpl.cancel()merges statement-local settings into a copy and callsclearSession()before issuingKILL QUERY(includingON CLUSTERwhen configured).Unit tests cover
clearSession()behavior; integration tests cancel long-running SELECT and INSERT inside a session. CHANGELOG documents the fix under 0.10.0.Reviewed by Cursor Bugbot for commit df1a530. Bugbot is set up for automated code reviews on this repo. Configure here.