Skip to content

jdbc-v2: session_id not accepted as a connection property, and cancel() doesn't strip a custom_http_params session_id → SESSION_IS_LOCKED #2881

@vprotasov

Description

@vprotasov

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:generalgeneral issue without a specific area.bugjdbc-v2jdbc-v2 issues

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions