When attempting to upload a CSV file (~100 lines and < 100KB) to ClickHouseContainer running in junit, the client is timing out with the following error:
An exception or error caused a run to abort: Code: 159. Execution timed out, server ClickHouseNode [uri=any://localhost:51733/default]@675749754
I have the following code to initialize a ClickHouseContainer
val image: ClickHouseContainer =
new ClickHouseContainer("clickhouse/clickhouse-server:latest")
.withUrlParam("compress_algorithm", "zstd")
.withUsername("default")
.withPassword("")
.withExposedPorts(8123, 8443, 9000, 9440)
.waitingFor(
Wait
.forHttp("/ping")
.forPort(8123)
.forStatusCode(200)
.withStartupTimeout(Duration.ofSeconds(600)));
image.start()
Once the container starts, I am using ClickHouseClient to load the table from a CSV file.
val server = ClickHouseNode.builder
.host(image.getHost)
.port(image.getMappedPort(ClickHouseProtocol.HTTP.getDefaultPort))
.database("default")
.credentials(ClickHouseCredentials.fromUserAndPassword("default", ""))
.build
// Create a CSV file reference
val file = ClickHouseFile.of(csvFile, ClickHouseCompression.NONE, ClickHouseFormat.CSV)
// Create a client
val client = ClickHouseClient.newInstance(server.getProtocol)
// Specify settings, load data to the specified table and wait for completion
client
.write(server)
.set("input_format_csv_skip_first_lines", "0")
.set("format_csv_delimiter", ",")
.table(tableName)
.data(file)
.executeAndWait()
I even tried increasing the socket timeout on the client, but this did not help and instead I was getting connect reset by peer.
val client = ClickHouseClient
.builder()
.option(ClickHouseClientOption.SOCKET_TIMEOUT, 10000)
.option(ClickHouseClientOption.MAX_THREADS_PER_CLIENT, 100)
.option(ClickHouseClientOption.MAX_EXECUTION_TIME, 1000)
.build()
The CSV file is too small, hence I don't expect that inserting the rows to clickhouse should take so long.