Skip to content

Commit 6ded7ae

Browse files
committed
fixes inconsistency in max_execution_time
1 parent fc1a80b commit 6ded7ae

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.9.9
2+
3+
### Bug Fixes
4+
5+
- **[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)
6+
17
## 0.9.8
28

39
### Improvements

client-v2/src/main/java/com/clickhouse/client/api/Client.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -667,10 +667,12 @@ public Builder setProxyCredentials(String user, String pass) {
667667
}
668668

669669
/**
670-
* Sets the maximum time for operation to complete. By default, it is set to 3 hours.
671-
* @param timeout
672-
* @param timeUnit
673-
* @return
670+
* Sets the maximum time for operation to complete. By default, it is unlimited.
671+
* Value is saved in milliseconds always.
672+
*
673+
* @param timeout value of the timeout
674+
* @param timeUnit time unit of the timeout value
675+
* @return this instance
674676
*/
675677
public Builder setExecutionTimeout(long timeout, ChronoUnit timeUnit) {
676678
this.configuration.put(ClientConfigProperties.MAX_EXECUTION_TIME.getKey(), String.valueOf(Duration.of(timeout, timeUnit).toMillis()));
@@ -1958,10 +1960,10 @@ private TableSchema getTableSchemaImpl(
19581960
QuerySettings settings = new QuerySettings().setDatabase(database);
19591961
try (QueryResponse response = operationTimeout == 0
19601962
? query(describeQuery, queryParams, settings).get()
1961-
: query(describeQuery, queryParams, settings).get(getOperationTimeout(), TimeUnit.SECONDS)) {
1963+
: query(describeQuery, queryParams, settings).get(operationTimeout, TimeUnit.MILLISECONDS)) {
19621964
return TableSchemaParser.readTSKV(response.getInputStream(), name, originalQuery, database);
19631965
} catch (TimeoutException e) {
1964-
throw new ClientException("Operation has likely timed out after " + getOperationTimeout() + " seconds.", e);
1966+
throw new ClientException("Operation has likely timed out after " + getOperationTimeout() + " milliseconds.", e);
19651967
} catch (ExecutionException e) {
19661968
throw new ClientException("Failed to get table schema", e.getCause());
19671969
} catch (ServerException e) {
@@ -2118,7 +2120,10 @@ public Map<String, String> getConfiguration() {
21182120
return readOnlyConfig;
21192121
}
21202122

2121-
/** Returns operation timeout in seconds */
2123+
/**
2124+
* Returns operation ({@link ClientConfigProperties#MAX_EXECUTION_TIME}) timeout value in milliseconds.
2125+
* @return timeout value in milliseconds.
2126+
*/
21222127
protected int getOperationTimeout() {
21232128
return ClientConfigProperties.MAX_EXECUTION_TIME.getOrDefault(configuration);
21242129
}

0 commit comments

Comments
 (0)