From 6ded7aeab6b23ec7a5d760d86f181ccd3bfda1a3 Mon Sep 17 00:00:00 2001 From: Sergey Chernov Date: Tue, 21 Apr 2026 20:33:56 -0700 Subject: [PATCH] fixes inconsistency in max_execution_time --- CHANGELOG.md | 6 ++++++ .../com/clickhouse/client/api/Client.java | 19 ++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f836a5c89..784d4ee5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.9.9 + +### Bug Fixes + +- **[client-v2]** Fixed inconsistent use of `executionTimeout` parameter in `Client` component. The timeout was previously set in milliseconds but mistakenly retrieved and used in seconds in some places. Now it correctly uses milliseconds consistently. (https://github.com/ClickHouse/clickhouse-java/issues/2358) + ## 0.9.8 ### Improvements diff --git a/client-v2/src/main/java/com/clickhouse/client/api/Client.java b/client-v2/src/main/java/com/clickhouse/client/api/Client.java index d4f979026..c32095e78 100644 --- a/client-v2/src/main/java/com/clickhouse/client/api/Client.java +++ b/client-v2/src/main/java/com/clickhouse/client/api/Client.java @@ -667,10 +667,12 @@ public Builder setProxyCredentials(String user, String pass) { } /** - * Sets the maximum time for operation to complete. By default, it is set to 3 hours. - * @param timeout - * @param timeUnit - * @return + * Sets the maximum time for operation to complete. By default, it is unlimited. + * Value is saved in milliseconds always. + * + * @param timeout value of the timeout + * @param timeUnit time unit of the timeout value + * @return this instance */ public Builder setExecutionTimeout(long timeout, ChronoUnit timeUnit) { this.configuration.put(ClientConfigProperties.MAX_EXECUTION_TIME.getKey(), String.valueOf(Duration.of(timeout, timeUnit).toMillis())); @@ -1958,10 +1960,10 @@ private TableSchema getTableSchemaImpl( QuerySettings settings = new QuerySettings().setDatabase(database); try (QueryResponse response = operationTimeout == 0 ? query(describeQuery, queryParams, settings).get() - : query(describeQuery, queryParams, settings).get(getOperationTimeout(), TimeUnit.SECONDS)) { + : query(describeQuery, queryParams, settings).get(operationTimeout, TimeUnit.MILLISECONDS)) { return TableSchemaParser.readTSKV(response.getInputStream(), name, originalQuery, database); } catch (TimeoutException e) { - throw new ClientException("Operation has likely timed out after " + getOperationTimeout() + " seconds.", e); + throw new ClientException("Operation has likely timed out after " + getOperationTimeout() + " milliseconds.", e); } catch (ExecutionException e) { throw new ClientException("Failed to get table schema", e.getCause()); } catch (ServerException e) { @@ -2118,7 +2120,10 @@ public Map getConfiguration() { return readOnlyConfig; } - /** Returns operation timeout in seconds */ + /** + * Returns operation ({@link ClientConfigProperties#MAX_EXECUTION_TIME}) timeout value in milliseconds. + * @return timeout value in milliseconds. + */ protected int getOperationTimeout() { return ClientConfigProperties.MAX_EXECUTION_TIME.getOrDefault(configuration); }