When a long-running query holds that HTTP session, StatementImpl.cancel() issues KILL QUERY over the same connection. Because the session id is carried in custom_http_params, the KILL becomes a second concurrent request in the locked session and the server returns 373 SESSION_IS_LOCKED. The query is never cancelled.
PR #2868 added clearSession() and strips session_id/session_check/session_timeout from the internally issued KILL QUERY — but it does not touch custom_http_params, so a session id provided that way is still sent with the KILL and the cancel still fails.
Steps to reproduce
▎ 1. Connect with the v2 driver, setting custom_http_params=session_id=my_session.
▎ 2. Start a long-running query (e.g. SELECT sleep(3) FROM numbers(100)).
▎ 3. From the same Statement, call cancel().
▎ 4. Observe KILL QUERY fails with Code: 373. DB::Exception: Session ... is locked by a concurrent client; the query runs to completion.
Requests (either or both)
▎ 1. Preferred: accept session_id (and session_check/session_timeout) as first-class jdbc-v2 connection properties, so clients don't have to use custom_http_params for sessions at all.
▎ 2. Have cancel() also detect and strip a session_id carried in custom_http_params from the internally issued KILL QUERY (extending #2868), so it isn't blocked by the session lock.
Option 1 also lets the existing clearSession() logic from #2868 handle cancel correctly without any client-side workaround.
related:
#871
When a long-running query holds that HTTP session, StatementImpl.cancel() issues KILL QUERY over the same connection. Because the session id is carried in custom_http_params, the KILL becomes a second concurrent request in the locked session and the server returns 373 SESSION_IS_LOCKED. The query is never cancelled.
PR #2868 added clearSession() and strips session_id/session_check/session_timeout from the internally issued KILL QUERY — but it does not touch custom_http_params, so a session id provided that way is still sent with the KILL and the cancel still fails.
Steps to reproduce
▎ 1. Connect with the v2 driver, setting custom_http_params=session_id=my_session.
▎ 2. Start a long-running query (e.g. SELECT sleep(3) FROM numbers(100)).
▎ 3. From the same Statement, call cancel().
▎ 4. Observe KILL QUERY fails with Code: 373. DB::Exception: Session ... is locked by a concurrent client; the query runs to completion.
Requests (either or both)
▎ 1. Preferred: accept session_id (and session_check/session_timeout) as first-class jdbc-v2 connection properties, so clients don't have to use custom_http_params for sessions at all.
▎ 2. Have cancel() also detect and strip a session_id carried in custom_http_params from the internally issued KILL QUERY (extending #2868), so it isn't blocked by the session lock.
Option 1 also lets the existing clearSession() logic from #2868 handle cancel correctly without any client-side workaround.
related:
#871