You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bugconnectivityArea: connection, TLS, pool, timeouts, cancellation, transport, compressionjdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)needs-infoWaiting for information from the issue author
After upgrading ClickHouse from 21.11 to 24.8.14.39, reading some tables results in an error: Caused by: org.apache.http.TruncatedChunkException: Truncated chunk (expected size: 4096; actual size: 4088). I then deployed two sets of ClickHouse and recreated and migrated the problematic tables, but the result was the same. Reading in 21.11 worked fine, while the 24 version gave an error. I'm using Spark 3.4.4 and clickhouse-jdbc 0.7.2, and even after testing with the latest JDBC version 0.9.8, the error still occurs. From what I found online, I suspect it's caused by the HTTP transmission protocol? Since I have to use a higher version of ClickHouse, is there a way to fix this issue in version 24?
nfo: org. ache.spark,SparkEcept ion: Job abor ted due to stage foure: Tsk D in stage . falled 4 tines, mst reent fa
shangjian-spark-workero executor O): Java.sql. S0L Excption org.apache.hc.cores. http. TruncatedChunkException: Truncated chunk (expected size: 104s576: a
com.clickhouse.jdbc.SqlExceptionUtils.create(SqlExceptionUtils.java:45)
at org.apache.spark.util.NextIterator.hasNext(NextIterator.scala:73)
at org.apache.spark.InterruptibleIterator .hasNext(InterruptibleIterator.scala:37
at org.apache.spark.util.CompletionIterator.hasNext(CompletionIterator.scala:31)
org. apache. spark.sql. catalyst.expressions. GeneratedclasssGeneratedIteratorFor codegenStagel.processNext(Unknown Source)
at org.apache.spark.sql.execution.BufferedRowIterator .hasNext(BufferedRowIterator.java:43)
at org.apache. spark.sql.execution.wholeStageCodegenExec$$anons1. hasNext(wholeStageCodegenExec.scala:760)
at org. apache.spark.sql.execut ion.UnsafeExternalRowSor ter.sort(UnsafeExternalRowsorter.java:225)
at org.apache. spark,sql.execut ion.exchange. ShuffleExchangeExecs.fanonfunsprepareShufflebependency 1o(ShuffleExchangeExec.scala:369)
at org.apache. spark.rdd. RDD.$anonfun$mapPartitionsInternal$2(RD0.scala:888)
org.apache. spark.rdd. RDD.$anonfun$mapPartitionsInternal$2$adapted(RDD. scala:888)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:328)
org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:52)
at org.apache.spark.rdd.RDD.computeorReadCheckpoint(RDD.scala:364
at org.apache.spark.rdd.RDD.iterator(RDD.scala:328)
at org.apache.spark.shuffle.ShufflewriteProcessor.write(ShufflewriteProcessor.scala:59)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:101)
org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:53)
at org.apache.spark.TaskContext.runTaskWithListeners(TaskContext.scala:161)
at org.apache.spark.scheduler.Task.run(Task.scala:139)
at org.apache.spark.executor .Executor$TaskRunner.$anonfun$run$3(Executor.scala:554)
at org.apache.spark.executor.Executor$TaskRunner. run(Executooocaleitor
org.apache.spark.util.Utils$.tryWithsafeFinally(Utils.scala:1529
:624
at java.util.concurrent. ThreadPoolExecutor. runWorker (ThreadPoolExecutor .java:1149)
java.util.concurrent. ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
java.lang.Thread.run(Thread.java:750)
by: org.apache.hc.core5.http. TruncatedChunkException: Truncated chunk (expected size: 1048576; actual size: 634357)
at org.apache.hc.core5.http.impl. io.ChunkedInputStream. read(ChunkedInputStream. java:198)
at org.apache.hc.core5.http. io.EofSensor InputStream. read(EofSensor InputStream. java:135)
at com.clickhouse.data.stream.WrappedInputStream.updateBuf fer (WrappedInputStream. java:30)
at com. clickhouse. data.stream.AbstractByteArrayInputStream. readBytes (AbstractByteArrayInputStream.java:335)
at com. clickhouse.data.stream.AbstractByteArrayInputStream. readBuf fer(AbstractByteArrayInputStream.java:166)
at com.clickhouse.data.ClickHouseInputStream. readString(ClickHouseInputStream. java:1046)
at com. clickhouse.data.ClickHouseInputStream. readunicodeString(ClickHouseInputStream. java:1082)
at com.clickhouse.data. format.BinaryDataProcessor .readTextString(BinaryDataProcessor.java:678)
at com.clickhouse.data. format.ClickHouseRowBinaryProcessor. readAndFill(ClickHouseRowBinaryProcessor.java:254)
at com.clickhouse.data.ClickHouseDataProcessor .nextRecord(ClickHouseDataProcessor. java:204)
at com.clickhouse.data.ClickHouseDataProcessor .access$200(ClickHouseDataProcessor.java:25)
at com.clickhouse.data.ClickHouseDataProcessor$RecordsIterator.next(ClickHouseDataProcessor.java:124)
at com.clickhouse.data.ClickHouseDataProcessorsRecordsIterator. next(ClickHouseDataProcessor.java:110)
at com.clickhouse.jdbc.ClickHouseResultSet.next(ClickHouseResultSet. java:727)
more
Recommendation: Keep open — needs info from the reporter
Probably not a driver defect: the server ends the response when the reader stops reading for more than 30 s. Ask the reporter for the items in the Analysis.
Status on main: Needs info — with the issue's URL, a JDBC read that pauses 40 s after 1,000 rows fails with MalformedChunkCodingException (jdbc-v2 and the v1 driver); with a 5 s pause it reads all 20,000,000 rows. Ran on main (8480ca001), ClickHouse 24.8.14.39 and 26.11.2.4.
Workaround: if the server logs code 209, set http_send_timeout (for example 1800) in the server's default profile and restart the server: then the 40 s pause reads all rows on 24.8.14.39. The same setting as a query setting (URL parameter) has no effect.
Analysis: The exception means that the HTTP response ended inside a chunk. In the run, the server ended it: system.query_log has Code: 209. DB::Exception: Timeout exceeded while writing to socket (…, 30000 ms), because the reader did not read for longer than http_send_timeout. ClickHouse 23.6 changed this default from 180 s to 30 s (system.settings_changes), which can explain why 21.11 worked. Missing: the exception of the failed query in system.query_log (or the server error log at that time), and whether a proxy or load balancer is between Spark and the server.
Automated triage by Polyglot AI. A maintainer makes the final decision.
bugconnectivityArea: connection, TLS, pool, timeouts, cancellation, transport, compressionjdbcModule: the JDBC driver (jdbc-v2; with legacy: the v1 driver)needs-infoWaiting for information from the issue author
Activity
nanjing922 commentedon Oct 21, 2026
Is there any setting or switch to restore it to the functionality from 21.11?
nanjing922 commentedon Oct 21, 2026
nfo: org. ache.spark,SparkEcept ion: Job abor ted due to stage foure: Tsk D in stage . falled 4 tines, mst reent fa
shangjian-spark-workero executor O): Java.sql. S0L Excption org.apache.hc.cores. http. TruncatedChunkException: Truncated chunk (expected size: 104s576: a
com.clickhouse.jdbc.SqlExceptionUtils.create(SqlExceptionUtils.java:45)
at org.apache.spark.util.NextIterator.hasNext(NextIterator.scala:73)
at org.apache.spark.InterruptibleIterator .hasNext(InterruptibleIterator.scala:37
at org.apache.spark.util.CompletionIterator.hasNext(CompletionIterator.scala:31)
org. apache. spark.sql. catalyst.expressions. GeneratedclasssGeneratedIteratorFor codegenStagel.processNext(Unknown Source)
at org.apache.spark.sql.execution.BufferedRowIterator .hasNext(BufferedRowIterator.java:43)
at org.apache. spark.sql.execution.wholeStageCodegenExec$$anons1. hasNext(wholeStageCodegenExec.scala:760)
at org. apache.spark.sql.execut ion.UnsafeExternalRowSor ter.sort(UnsafeExternalRowsorter.java:225)
at org.apache. spark,sql.execut ion.exchange. ShuffleExchangeExecs.fanonfunsprepareShufflebependency 1o(ShuffleExchangeExec.scala:369)
at org.apache. spark.rdd. RDD.$anonfun$mapPartitionsInternal$2(RD0.scala:888)
org.apache. spark.rdd. RDD.$anonfun$mapPartitionsInternal$2$adapted(RDD. scala:888)
at org.apache.spark.rdd.RDD.iterator(RDD.scala:328)
org.apache.spark.rdd.MapPartitionsRDD.compute(MapPartitionsRDD.scala:52)
at org.apache.spark.rdd.RDD.computeorReadCheckpoint(RDD.scala:364
at org.apache.spark.rdd.RDD.iterator(RDD.scala:328)
at org.apache.spark.shuffle.ShufflewriteProcessor.write(ShufflewriteProcessor.scala:59)
at org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:101)
org.apache.spark.scheduler.ShuffleMapTask.runTask(ShuffleMapTask.scala:53)
at org.apache.spark.TaskContext.runTaskWithListeners(TaskContext.scala:161)
at org.apache.spark.scheduler.Task.run(Task.scala:139)
at org.apache.spark.executor .Executor$TaskRunner.$anonfun$run$3(Executor.scala:554)
at org.apache.spark.executor.Executor$TaskRunner. run(Executooocaleitor
org.apache.spark.util.Utils$.tryWithsafeFinally(Utils.scala:1529
:624
at java.util.concurrent. ThreadPoolExecutor. runWorker (ThreadPoolExecutor .java:1149)
java.util.concurrent. ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
java.lang.Thread.run(Thread.java:750)
by: org.apache.hc.core5.http. TruncatedChunkException: Truncated chunk (expected size: 1048576; actual size: 634357)
at org.apache.hc.core5.http.impl. io.ChunkedInputStream. read(ChunkedInputStream. java:198)
at org.apache.hc.core5.http. io.EofSensor InputStream. read(EofSensor InputStream. java:135)
at com.clickhouse.data.stream.WrappedInputStream.updateBuf fer (WrappedInputStream. java:30)
at com. clickhouse. data.stream.AbstractByteArrayInputStream. readBytes (AbstractByteArrayInputStream.java:335)
at com. clickhouse.data.stream.AbstractByteArrayInputStream. readBuf fer(AbstractByteArrayInputStream.java:166)
at com.clickhouse.data.ClickHouseInputStream. readString(ClickHouseInputStream. java:1046)
at com. clickhouse.data.ClickHouseInputStream. readunicodeString(ClickHouseInputStream. java:1082)
at com.clickhouse.data. format.BinaryDataProcessor .readTextString(BinaryDataProcessor.java:678)
at com.clickhouse.data. format.ClickHouseRowBinaryProcessor. readAndFill(ClickHouseRowBinaryProcessor.java:254)
at com.clickhouse.data.ClickHouseDataProcessor .nextRecord(ClickHouseDataProcessor. java:204)
at com.clickhouse.data.ClickHouseDataProcessor .access$200(ClickHouseDataProcessor.java:25)
at com.clickhouse.data.ClickHouseDataProcessor$RecordsIterator.next(ClickHouseDataProcessor.java:124)
at com.clickhouse.data.ClickHouseDataProcessorsRecordsIterator. next(ClickHouseDataProcessor.java:110)
at com.clickhouse.jdbc.ClickHouseResultSet.next(ClickHouseResultSet. java:727)
more
nanjing922 commentedon Oct 21, 2026
class ClickHouseSource(option: Map[String, Any], spark: SparkSession) extends JDBCSourceBase(option, spark) {
override val driver: String = "com.clickhouse.jdbc.ClickHouseDriver"
override def url: String = s"jdbc:clickhouse://$host:$port/$db?compress=0"
jdbc : 0.7.2
spark: 3.4.2
nanjing922 commentedon Oct 23, 2026
Can someone help me take a look at this problem
polyglotAI-bot commentedon Nov 27, 2026
Recommendation: Keep open — needs info from the reporter
Probably not a driver defect: the server ends the response when the reader stops reading for more than 30 s. Ask the reporter for the items in the Analysis.
main: Needs info — with the issue's URL, a JDBC read that pauses 40 s after 1,000 rows fails withMalformedChunkCodingException(jdbc-v2 and the v1 driver); with a 5 s pause it reads all 20,000,000 rows. Ran onmain(8480ca001), ClickHouse 24.8.14.39 and 26.11.2.4.http_send_timeout(for example1800) in the server'sdefaultprofile and restart the server: then the 40 s pause reads all rows on 24.8.14.39. The same setting as a query setting (URL parameter) has no effect.Analysis: The exception means that the HTTP response ended inside a chunk. In the run, the server ended it:
system.query_loghasCode: 209. DB::Exception: Timeout exceeded while writing to socket (…, 30000 ms), because the reader did not read for longer thanhttp_send_timeout. ClickHouse 23.6 changed this default from 180 s to 30 s (system.settings_changes), which can explain why 21.11 worked. Missing: theexceptionof the failed query insystem.query_log(or the server error log at that time), and whether a proxy or load balancer is between Spark and the server.Automated triage by Polyglot AI. A maintainer makes the final decision.