Skip to content

Commit b54a2de

Browse files
authored
Merge pull request #2943 from ClickHouse/sync/release_0.10.0
Sync/release 0.10.0: Request Cancellation
2 parents a3ccce4 + 9300d79 commit b54a2de

18 files changed

Lines changed: 1530 additions & 209 deletions

File tree

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@
115115
previously set in milliseconds but mistakenly retrieved and used in seconds in some places. Now it correctly uses
116116
milliseconds consistently. (https://github.com/ClickHouse/clickhouse-java/issues/2358)
117117

118+
- **[client-v2]** HTTP `503 Service Unavailable` responses are now surfaced as a connection-style failure (
119+
`java.net.ConnectException`) and are retried by default. Previously a `503` was treated as a server error (
120+
`ServerException`) and fell under the `ServerRetryable` fault cause. It has been moved to the `ConnectTimeout` fault
121+
cause category so that connectivity/availability failures are handled uniformly with other connection errors. Callers
122+
that specifically excluded `ServerRetryable` to avoid retrying `503` should now adjust their
123+
`client_retry_on_failures` configuration to exclude `ConnectTimeout` instead.
124+
125+
- **[client-v2]** Unexpected/unknown HTTP status codes (those the client cannot interpret as a ClickHouse response) now
126+
throw a `ClientException` instead of a `ServerException`. Since the client cannot meaningfully handle these responses,
127+
they are reported as a client-side error rather than being attributed to the server.
128+
118129
### New Features
119130

120131
- **[client-v2, jdbc-v2]** Added support for an application-supplied `javax.net.ssl.SSLContext`. In client-v2,
@@ -181,6 +192,12 @@
181192
supported but will be removed. Please migrate to the new property.
182193
(https://github.com/ClickHouse/clickhouse-java/issues/2858)
183194

195+
- **[client-v2]** Added `Client#cancelTransportRequest(String queryId)` to cancel an in-flight request that has not yet
196+
received a response from the server, identified by the query id supplied in the operation settings. This aborts the
197+
request on the client side (cancels the underlying IO operation) but does **not** issue a `KILL QUERY` on the server,
198+
so a query that already started executing may continue to run server-side. It is recommended to use operation timeout
199+
settings where possible; this API is intended for explicitly aborting a request from the client.
200+
184201
### Improvements
185202

186203
- **[jdbc-v2, client-v2]** Added support of hostnames with underscore (`_`) in them. Now it is possible to specify endpoint

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

Lines changed: 157 additions & 103 deletions
Large diffs are not rendered by default.

client-v2/src/main/java/com/clickhouse/client/api/http/ClickHouseHttpProto.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ public class ClickHouseHttpProto {
8484
*/
8585
public static final String QPARAM_QUERY_STMT = "query";
8686

87+
public static final String QPARAM_ENABLE_HTTP_COMPRESSION = "enable_http_compression";
88+
89+
public static final String QPARAM_COMPRESS = "compress";
90+
91+
public static final String QPARAM_DECOMPRESS = "decompress";
92+
8793
public static final int DEFAULT_HTTP_PORT = 8123;
8894

8995
public static final int DEFAULT_HTTPS_PORT = 8443;

client-v2/src/main/java/com/clickhouse/client/api/insert/InsertResponse.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
import com.clickhouse.client.api.http.ClickHouseHttpProto;
44
import com.clickhouse.client.api.metrics.OperationMetrics;
55
import com.clickhouse.client.api.metrics.ServerMetrics;
6+
import com.clickhouse.client.api.transport.internal.TransportResponse;
67

7-
import java.util.Collections;
88
import java.util.Map;
99

1010
public class InsertResponse implements AutoCloseable {
1111
private OperationMetrics operationMetrics;
1212
private final Map<String, String> responseHeaders;
1313

14-
public InsertResponse(OperationMetrics metrics) {
15-
this(metrics, Collections.emptyMap());
16-
}
17-
18-
public InsertResponse(OperationMetrics metrics, Map<String, String> responseHeaders) {
14+
public InsertResponse(TransportResponse transportResponse, OperationMetrics metrics) {
1915
this.operationMetrics = metrics;
20-
this.responseHeaders = responseHeaders;
16+
this.responseHeaders = transportResponse.getHeaders();
2117
}
2218

2319
@Override

client-v2/src/main/java/com/clickhouse/client/api/internal/ClientUtils.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.clickhouse.client.api.internal;
22

3+
import org.slf4j.Logger;
4+
5+
import java.io.Closeable;
6+
37
/**
48
* Class containing utility methods used across the client.
59
*/
@@ -14,4 +18,14 @@ public static boolean isNotBlank(String str) {
1418
public static boolean isBlank(String str) {
1519
return str == null || str.trim().isEmpty();
1620
}
21+
22+
public static void quietClose(Closeable closeable, Logger log) {
23+
if (closeable != null) {
24+
try {
25+
closeable.close();
26+
} catch (Exception e) {
27+
log.warn("Failed to close object " + closeable, e);
28+
}
29+
}
30+
}
1731
}

0 commit comments

Comments
 (0)