Hi! I'm getting a weird error on my clickhouse -&g...
# replication-troubleshooting
d
Hi! I'm getting a weird error on my clickhouse -> postgres connection
Copy code
source connector ClickHouse v0.2.6
destination Postgres v2.2.1
airbyte version 0.50.31 (I know, I know)
The error appears after a bit syncing incremental models, and it seems to be
Copy code
java.sql.SQLException: java.io.IOException: Premature EOF
A full refresh takes around 1.22H and it does not disconnect though. I've set
socket_timeout=300000
in my connection with no success. What can it be?
k
Based on the knowledge sources, I can see that "Premature EOF" errors have been reported in Airbyte, though the specific case you're describing (ClickHouse source to Postgres destination) isn't directly covered in the available documentation. From the knowledge sources, I found a similar "Premature EOF" error reported for a [BigQuery to PostgreSQL sync](https://github.com/airbytehq/airbyte/issues/27999), where the error occurred after syncing approximately 12 GB of data. The error manifested as:
Copy code
java.io.EOFException: Failure reason: com.google.cloud.bigquery.BigQueryException: Premature EOF
However, the knowledge sources don't provide a definitive solution for this specific error pattern with ClickHouse as a source. Regarding your timeout configuration, I found that there's a known issue with ClickHouse connections. According to a [GitHub issue about ClickHouse destination timeouts](https://github.com/airbytehq/airbyte/issues/29005), even when JDBC parameters like
socket_timeout
are specified, they may not be properly respected due to hardcoded timeout values in the connector (60 seconds for connection checks). Additionally, there's a [forum discussion about ClickHouse timeout issues](https://discuss.airbyte.io/t/482) that mentions ClickHouse JDBC uses HTTP by default, which can timeout after a minute, and the recommended fix is to adjust the
socket_timeout
parameter in the JDBC connection string. Given that: 1. Your full refresh works (1.22 hours) but incremental syncs fail 2. You're using an older Airbyte version (0.50.31) 3. The error occurs "after a bit" of syncing I'd recommend: - Upgrading to a more recent Airbyte version, as timeout handling may have been improved - Checking if there are any network stability issues between your ClickHouse source and Airbyte instance - Reviewing the ClickHouse source connector logs for more detailed error information Unfortunately, the knowledge sources don't contain enough specific information about this exact error scenario (ClickHouse source with "Premature EOF" during incremental syncs) to provide a definitive solution.
d
@kapa.ai consider now the following excerpt from the logs. Does this update your answer?
Copy code
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:140)
                at io.airbyte.commons.util.CompositeIterator.computeNext(CompositeIterator.java:74)
                at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:145)
                at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:140)
                at io.airbyte.commons.util.DefaultAutoCloseableIterator.computeNext(DefaultAutoCloseableIterator.java:42)
                at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:145)
                at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:140)
                at io.airbyte.commons.util.DefaultAutoCloseableIterator.computeNext(DefaultAutoCloseableIterator.java:42)
                at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:145)
                at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:140)
                at java.base/java.util.Iterator.forEachRemaining(Iterator.java:132)
                at io.airbyte.cdk.integrations.base.IntegrationRunner.produceMessages(IntegrationRunner.java:236)
                at io.airbyte.cdk.integrations.base.IntegrationRunner.readSerial(IntegrationRunner.java:276)
                ... 3 more
        Caused by: java.io.IOException: Premature EOF
                at java.base/sun.net.www.http.ChunkedInputStream.readAheadBlocking(ChunkedInputStream.java:567)
                at java.base/sun.net.www.http.ChunkedInputStream.readAhead(ChunkedInputStream.java:611)
                at java.base/sun.net.www.http.ChunkedInputStream.read(ChunkedInputStream.java:705)
                at java.base/java.io.FilterInputStream.read(FilterInputStream.java:119)
                at java.base/sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3692)
                at com.clickhouse.client.stream.Lz4InputStream.readFully(Lz4InputStream.java:34)
                at com.clickhouse.client.stream.Lz4InputStream.updateBuffer(Lz4InputStream.java:72)
                at com.clickhouse.client.stream.AbstractByteArrayInputStream.ensureOpen(AbstractByteArrayInputStream.java:36)
                at com.clickhouse.client.stream.AbstractByteArrayInputStream.readBytes(AbstractByteArrayInputStream.java:229)
                at com.clickhouse.client.data.ClickHouseRowBinaryProcessor$MappedFunctions.lambda$buildMappingsForDataTypes$64(ClickHouseRowBinaryProcessor.java:336)
                at com.clickhouse.client.data.ClickHouseRowBinaryProcessor$MappedFunctions.deserialize(ClickHouseRowBinaryProcessor.java:466)
                at com.clickhouse.client.data.ClickHouseRowBinaryProcessor.readAndFill(ClickHouseRowBinaryProcessor.java:509)
                at com.clickhouse.client.ClickHouseDataProcessor.nextRecord(ClickHouseDataProcessor.java:143)
                at com.clickhouse.client.ClickHouseDataProcessor.access$100(ClickHouseDataProcessor.java:21)
                at com.clickhouse.client.ClickHouseDataProcessor$RecordsIterator.next(ClickHouseDataProcessor.java:36)
                at com.clickhouse.client.ClickHouseDataProcessor$RecordsIterator.next(ClickHouseDataProcessor.java:22)
                at com.clickhouse.jdbc.ClickHouseResultSet.next(ClickHouseResultSet.java:714)
                ... 39 more
Caused by: [CIRCULAR REFERENCE: java.sql.SQLException: java.io.IOException: Premature EOF]
k
A message from kapa.ai
New message text here
d
@kapa.ai What can you say about the last part in the logs where a Circular reference is mentioned?
Caused by: [CIRCULAR REFERENCE: java.sql.SQLException: java.io.IOException: Premature EOF]
k
A message from kapa.ai
The "CIRCULAR REFERENCE" notation in the stack trace is a Java logging mechanism that prevents infinite loops when printing exception stack traces. It indicates that the same exception object appears multiple times in the exception chain, and the logging framework is avoiding printing the full stack trace again to prevent redundancy. In your specific case:
Copy code
Caused by: [CIRCULAR REFERENCE: java.sql.SQLException: java.io.IOException: Premature EOF]
This means that the
java.sql.SQLException
wrapping the
java.io.IOException: Premature EOF
has already been printed earlier in the stack trace. The logging framework detected that printing it again would create a circular reference in the exception chain, so it simply notes this with the "CIRCULAR REFERENCE" marker instead of repeating the entire stack trace. This is actually a normal Java behavior and not indicative of a separate problem. The real issue is still the underlying
java.io.IOException: Premature EOF
that occurs when the ClickHouse JDBC driver is reading data over HTTP with LZ4 compression, as I explained in my previous response. The circular reference notation is just telling you that the exception chain loops back on itself (likely because the SQLException wraps the IOException, which was already shown higher in the stack trace), but it doesn't provide any additional diagnostic information about why the connection is being prematurely terminated.
d
@kapa.ai how can I verify that the value for
socket_timeout
has been applied correctly? Also, why is this error not happening during full refreshes?
k
A message from kapa.ai
Based on the knowledge sources, I can provide some insights about verifying the
socket_timeout
parameter and why full refreshes might behave differently. ## Verifying socket_timeout Application Unfortunately, the knowledge sources indicate there's a known issue with JDBC parameter application in ClickHouse connectors. According to a [GitHub issue about ClickHouse JDBC parameters](https://github.com/airbytehq/airbyte/issues/25605), when configuring
JDBC URL params
via the UI, they are properly propagated to the config builder, but "according to
tcpdump
, the params from the config builder are not attached to the request to the destination DB." The issue suggests that the ClickHouse connector may not be properly passing configured JDBC parameters to the actual JDBC driver or connection, unlike other connectors such as Snowflake or MySQL that explicitly attach parameters to the JDBC URL. Additionally, a [forum discussion about PostgreSQL destination configuration](https://discuss.airbyte.io/t/935) mentions that a
jdbc_url_params
input was added to allow customization of JDBC parameters, but the knowledge sources don't explicitly confirm whether this feature is available or working correctly for the ClickHouse source connector in your version (0.50.31). ## Why Full Refreshes Work vs Incremental Syncs The knowledge sources don't explicitly explain why full refreshes would succeed while incremental syncs fail with the "Premature EOF" error. However, I can note that: 1. Full refresh and incremental sync operations use different query patterns and data reading mechanisms 2. Incremental syncs typically involve more complex queries with cursor/timestamp filtering 3. The connection behavior and data streaming patterns may differ between the two sync modes Unfortunately, the knowledge sources don't contain enough specific information to definitively explain why your full refresh (1.22 hours) completes successfully while incremental syncs fail with the same timeout configuration. Given the known issue with JDBC parameter application in the ClickHouse connector, it's possible that the
socket_timeout=300000
parameter you've configured isn't actually being applied to the underlying JDBC connection, which would explain why it hasn't resolved your issue.
d
@kapa.ai in the stacktrace appears the timestamp field
1763117201369
what format is this? Unix timestamps map it to 2106
k
A message from kapa.ai
Based on the knowledge sources, the timestamp
1763117201369
appears to be a Unix timestamp in milliseconds. According to the [DatetimeBasedCursor documentation](https://docs.airbyte.com/platform/1.8/connector-development/config-based/understanding-the-yaml-file/reference#/definitions/DatetimeBasedCursor), Airbyte supports several timestamp formats including: - %s: Epoch unix timestamp in seconds -
1686218963
- %ms: Epoch unix timestamp in milliseconds -
1686218963123
- %s_as_float: Epoch unix timestamp in seconds as float with microsecond precision -
1686218963.123456
Your timestamp
1763117201369
has 13 digits, which is consistent with the millisecond format (%ms). If you convert
1763117201369
milliseconds to seconds by dividing by 1000, you get
1763117201.369
seconds, which maps to November 9, 2025 (not 2106 as you mentioned - that would be if you interpreted the full number as seconds). Additionally, the [JSON to Avro conversion documentation](https://docs.airbyte.com/platform/1.8/understanding-airbyte/json-avro-conversion#conversion-rules) confirms that Airbyte handles timestamps with microsecond precision, storing them as: > Timestamp (microsecond precision): The timestamp-micros logical type represents an instant on the global timeline, independent of a particular time zone or calendar, with a precision of one microsecond. A timestamp-micros logical type annotates an Avro long, where the long stores the number of microseconds from the unix epoch, 1 January 1970 000000.000000 UTC. So the timestamp format in your stack trace is Unix timestamp in milliseconds, which is a common format for representing precise timestamps in data systems.