ClickHouse / ClickHouse/clickhouse-java
Version client-v2-0.9.4 changes order of query settings as URL params in CH HTTP request
- Ngôn ngữ chính
- Java
- Star
- 1.6k
- Fork
- 636
- Merge trung bình
- 2 ngày 23 giờ
- Pull request đã merge (30 ngày)
- 29
Mô tả
## Once we upgraded from client-v2-0.9.0 to client-v2-0.9.4 we are seeing that in the final HTTP request made to clickhouse the order of the URL params is changing resulting in the change in behavior.
Since clickhouse processes the query settings in the same order, giving preference to the parameter coming later, in our case we are seeing the profile setting parameter going to the end resulting in the change in query result.
Query string in version 0.9.0
`http://localhost:18123?query_id=ddcb9fb8-b875-477f-b221-839b6ae2b375_http-nio-4010-exec-10_143&compress=1&role=event_interactive_reader&profile=event_interactive_reader_profile&prefer_global_in_and_join=0&log_comment=; role_s: [event_interactive_reader]; profile_s: event_interactive_reader_profile`
Query string in version 0.9.4
`http://localhost:18123?query_id=2dd8034a-c44f-4524-a51d-9022cb50b402_http-nio-4010-exec-1_449&compress=1&role=event_interactive_reader&log_comment=; role_s: [event_interactive_reader]; profile_s: event_interactive_reader_profile&prefer_global_in_and_join=1&profile=event_interactive_reader_profile`
If you see the profile parameter is going to the end resulting in the settings from the profile not allowing to override the prefer_global_in_and_join=1 value. Its defaulting to the value in the setting.
In version 0.9.0 the order of adding the setting to QuerySettings through serverSetting method was retained, but its breaking in 0.9.4
### Steps to reproduce
Have a profile settings and some query setting overriding the value in setting. Set the query setting on QuerySettings at the end in version 0.9.0 this is preserved in the final URL, but its not in 0.9.4.
### Error Log or Exception StackTrace
No errors as such, but due to the. different query settings being applied the result from clickhouse would vary. In our case the value of prefer_global_in_and_join was changing resulting in no data being returned.
### Expected Behaviour
### Code Example
```java
QuerySettings querySettings = new QuerySettings();
querySettings.setFormat(clickHouseFormat);
querySettings.setDBRoles(Set.of("event_interactive_reader"));
String readSettingsProfile = "event_interactive_reader_profile";
settings.put("profile", "event_interactive_reader_profile");
settings.put("prefer_global_in_and_join", "1");
querySettings.logComment("; role_s: [event_interactive_reader]; profile_s: event_interactive_reader_profile");
querySettings.setQueryId("2dd8034a-c44f-4524-a51d-9022cb50b402_http-nio-4010-exec-1_449");
QueryResponse queryResponse = client.query("select * from database.events", querySettings).get(getClientSocketTimeout(client), TimeUnit.MILLISECONDS);
```
If on the profile event_interactive_reader_profile if prefer_global_in_and_join is 0 then in client version 0.9.4 it will always be 0 as profile ends up in the end.
### Configuration
#### Client Configuration
```
com.clickhouse.client.api.Client client = new com.clickhouse.client.api.Client.Builder()
.addEndpoint(endpoint)
.setUsername(username)
.setPassword(password)
.setMaxConnections(10)
.setConnectionTTL(getPropertyOrDefault("clickhouse.client.connection.ttlMillis", 0L, Long::valueOf), ChronoUnit.MILLIS)
.setKeepAliveTimeout(getPropertyOrDefault("clickhouse.client.keepAlive.timeoutMillis", -1L, Long::valueOf), ChronoUnit.MILLIS)
.setConnectionReuseStrategy(ConnectionReuseStrategy.valueOf(getPropertyOrDefault("clickhouse.client.connection.reuseStrategy", "LIFO", String::valueOf)))
.setConnectTimeout(getPropertyOrDefault("clickhouse.client.connection.timeoutMillis", 5000L, Long::valueOf), ChronoUnit.MILLIS)
.setSocketTimeout(getPropertyOrDefault("clickhouse.client.default.socketTimeoutMillis", 30000L, Long::valueOf), ChronoUnit.MILLIS)
.build();
```
#### Environment
* [ ] Cloud
* Client version: client-v2-0.9.4
* Language version: Java
* OS: Debian
#### ClickHouse Server
* ClickHouse Server version: 25.3
* ClickHouse Server non-default settings, if any:
* `CREATE TABLE` statements for tables involved:
* Sample data for all these tables, use [clickhouse-obfuscator](https://github.com/ClickHouse/ClickHouse/blob/master/programs/obfuscator/Obfuscator.cpp#L42-L80) if necessary
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với QuerySettings, đặc biệt là đường dẫn serverSetting, và theo dõi cách các thiết lập được tập hợp trước khi client.query gửi yêu cầu. Tái hiện ví dụ profile và prefer_global_in_and_join được cung cấp với client-v2-0.9.4, đồng thời so sánh thứ tự URL cuối cùng với 0.9.0. Hoàn thành khi thứ tự chèn được giữ nguyên, để các thiết lập được thêm sau vẫn giữ được mức ưu tiên dự kiến.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- java
- Lĩnh vực
- api, databases
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 42/100