-
Notifications
You must be signed in to change notification settings - Fork 537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ClickHouse java client - reusing same instance of ClickHouseClient gives execution timeout after 10 inserts #1668
Comments
Why do you use |
@den-crane That was an experience, But I get the exact same behaviour, with or without that |
#1538 same problem? |
@occunha thank you for reporting the issue. I suspect it happens because some internal timer is not stopped and continues because you are reusing the request object. |
Thank @shilaidun! It is a good idea to check it. Will do. |
Good day, public void write() {
try (ClickHouseClient client = getClient()) {
ClickHouseRequest<?> read = client.read(getServer()).write();
for (int i = 0; i < 20; i++) {
System.out.println("Writing data. Iteration #" + i + " of 20.");
String id = UUID.randomUUID().toString();
String field1 = "field1" + (i);
String field2 = "field2" + (i);
String field3 = "field3" + (i);
String field4 = "field4" + (i);
String query = String.format("INSERT INTO mytable VALUES ('%s', '%s', '%s', '%s', '%s')",
id,
field1,
field2,
field3,
field4);
try (ClickHouseResponse resp = read.format(ClickHouseFormat.CustomSeparated)
.query(query)
.executeAndWait()) {
log.info("Response: {}", resp.getSummary());
} catch (Exception e) {
log.error("Failed to write data", e);
throw new RuntimeException(e);
}
}
} catch (Exception e) {
log.error("Failed to write data", e);
throw new RuntimeException(e);
}
} The class try (ClickHouseResponse resp = read.format(ClickHouseFormat.CustomSeparated)
.query(query)
.executeAndWait()) {
log.info("Response: {}", resp.getSummary());
} catch (Exception e) {
log.error("Failed to write data", e);
throw new RuntimeException(e);
} So object I see the problem is that query do not expect reading data from server and it would be good to make the client close response in such cases. |
I am new using clickhouse and I have assembled a project in java using java client.
This code only inserts 10 records, after that I get an Code: 159. Execution timed out Exception
I have already tried to change and add some ClickHouseClientOptions but I always get the same behaviour. How can I reuse the same client connections in clickhouse using java client?
The text was updated successfully, but these errors were encountered: