Skip to content

[jdbc-v2] Driver sends all profile settings as explicit HTTP parameters, overriding server-side defaults #2825

@Rutimich

Description

@Rutimich

Description

After upgrading ClickHouse server from 25.3 to 26.3 (which changed the default value of async_insert from 0 to 1), the setting remained 0 for all connections made via jdbc-v2, despite no explicit configuration on either client or server side.

Root Cause

jdbc-v2 explicitly sends all user profile settings as HTTP query parameters on every request. This means the driver's own hardcoded defaults override the server-side profile values.

Even though async_insert = 1 is set in the server profile, every query arrives at the server with async_insert=0 injected by the driver, which can be confirmed via system.query_log:

SELECT Settings['async_insert']
FROM system.query_log
WHERE type = 'QueryStart'
ORDER BY event_time DESC
LIMIT 5;
-- returns 0 for all jdbc-v2 connections

Full Settings map from system.query_log for a jdbc-v2 connection:

{max_query_size=2000000000, connect_timeout=30, connect_timeout_with_failover_ms=3000, 
connections_with_failover_max_tries=3, use_uncompressed_cache=0, load_balancing=random, 
distributed_aggregation_memory_efficient=1, max_bytes_before_external_group_by=20000000000, 
max_bytes_before_external_sort=20000000000, max_memory_usage=120000000000, async_insert=0}

The driver is sending the entire profile as explicit HTTP parameters, including async_insert=0.

For comparison, clickhouse-connect (Python) for the same user and server returns:

async_insert: value=1, changed=0

It doesn't touch the setting at all and lets the server use its own default.

Steps to Reproduce

  1. Use ClickHouse server 26.3+ (where async_insert default is 1)
  2. Connect via jdbc-v2 (tested with 0.9.7)
  3. Run:
SELECT value, changed FROM system.settings WHERE name = 'async_insert';
  1. Observe value=0, changed=1 - the driver has overridden the server default

What Was Tried

All of the following failed to override the driver-injected value:

  • Setting async_insert=1 in server profile (users.xml)
  • Setting async_insert=1 in JDBC URL as ?clickhouse_setting_async_insert=1
  • Setting async_insert=1 in Driver Properties / User Properties
  • Adding SET async_insert=1 as Connection Initialization SQL in DBeaver
  • Using profile constraints in users.xml:
<constraints>
    <async_insert>
        <readonly/>
    </async_insert>
</constraints>

This results in SETTING_CONSTRAINT_VIOLATION on connect because the driver sends async_insert=0 during the handshake, before any user-level constraints are applied.

The only workaround found is appending SETTINGS async_insert=1 to every individual query.

Expected Behavior

The driver should not explicitly send settings that were not configured by the user. Server profile settings belong to the server - the driver should only transmit settings that are explicitly set by the client, not shadow server-side defaults with its own hardcoded values.

Environment

  • ClickHouse server: 26.3
  • Driver: com.clickhouse:clickhouse-jdbc 0.9.7 (jdbc-v2)
  • Client: DBeaver 26.0.2
  • OS: Windows 11, JVM 21.0.8
  • http_user_agent: DBeaver 26.0.2 - Main jdbc-v2/0.9.7 clickhouse-java-v2/0.9.7 (Windows 11; jvm:21.0.8) Apache-HttpClient/5.4.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    investigatingInvestigation of a root cause is on goingjdbc-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