批量写入clickhouse出错,内存溢出,报错信息如下:
代码语言:javascript复制2021-07-20 13:59:14.291 INFO 12719 --- [pool-9-thread-1] c.t.r.c.c.consumer.ClickHouseConsumer : ------>>>>>>The 10 times write,Receive messages size is 74593
2021-07-20 13:59:24.401 INFO 12719 --- [pool-8-thread-1] c.t.r.c.c.consumer.ClickHouseConsumer : ------>>>>>>The 9 times write to default.roc_activity_base end.【Assemble takes 10164 ms,Insert takes 6033 ms】
2021-07-20 13:59:46.842 ERROR 12719 --- [pool-9-thread-1] c.t.r.c.c.consumer.ClickHouseConsumer : The 10 times write,Insert into clickhouse error:ClickHouse exception, code: 241, host: 10.58.10.243, port: 8123; Code: 241, e.displayText() = DB::Exception: Memory limit (total) exceeded: would use 3.33 GiB (attempt to allocate chunk of 4219140 bytes), maximum: 3.33 GiB (version 21.5.6.6 (official build))
ru.yandex.clickhouse.except.ClickHouseException: ClickHouse exception, code: 241, host: 10.58.10.243, port: 8123; Code: 241, e.displayText() = DB::Exception: Memory limit (total) exceeded: would use 3.33 GiB (attempt to allocate chunk of 4219140 bytes), maximum: 3.33 GiB (version 21.5.6.6 (official build))
at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.specify(ClickHouseExceptionSpecifier.java:58) ~[clickhouse-jdbc-0.2.4.jar:na]
at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.specify(ClickHouseExceptionSpecifier.java:28) ~[clickhouse-jdbc-0.2.4.jar:na]
at ru.yandex.clickhouse.ClickHouseStatementImpl.checkForErrorAndThrow(ClickHouseStatementImpl.java:875) ~[clickhouse-jdbc-0.2.4.jar:na]
at ru.yandex.clickhouse.ClickHouseStatementImpl.sendStream(ClickHouseStatementImpl.java:851) ~[clickhouse-jdbc-0.2.4.jar:na]
at ru.yandex.clickhouse.ClickHouseStatementImpl.sendStream(ClickHouseStatementImpl.java:824) ~[clickhouse-jdbc-0.2.4.jar:na]
at ru.yandex.clickhouse.ClickHouseStatementImpl.sendStream(ClickHouseStatementImpl.java:817) ~[clickhouse-jdbc-0.2.4.jar:na]
at ru.yandex.clickhouse.ClickHousePreparedStatementImpl.executeBatch(ClickHousePreparedStatementImpl.java:335) ~[clickhouse-jdbc-0.2.4.jar:na]
at ru.yandex.clickhouse.ClickHousePreparedStatementImpl.executeBatch(ClickHousePreparedStatementImpl.java:320) ~[clickhouse-jdbc-0.2.4.jar:na]
at cn.java4all.core.consumer.consumer.ClickHouseConsumer.onBulkMessage(ClickHouseConsumer.java:88) ~[classes/:na]
at cn.java4all.core.consumer.consumer.AbstractConsumer.doConsume(AbstractConsumer.java:69) [classes/:na]
at cn.fraudmetrix.module.kafka.consumer.ConcurrentPoller.lambda$handle$1(ConcurrentPoller.java:98) [module-kafka-3.2.3-20210716.082922-62.jar:na]
at java.util.concurrent.CompletableFuture$AsyncRun.run$$$capture(CompletableFuture.java:1626) ~[na:1.8.0_211]
at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java) ~[na:1.8.0_211]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_211]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_211]
at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_211]
Caused by: java.lang.Throwable: Code: 241, e.displayText() = DB::Exception: Memory limit (total) exceeded: would use 3.33 GiB (attempt to allocate chunk of 4219140 bytes), maximum: 3.33 GiB (version 21.5.6.6 (official build))
at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.specify(ClickHouseExceptionSpecifier.java:53) ~[clickhouse-jdbc-0.2.4.jar:na]
... 15 common frames omitted
2021-07-20 13:59:46.843 ERROR 12719 --- [pool-9-thread-1] c.t.r.c.c.consumer.AbstractConsumer : Consume the message error,topic is roc_dev_api_raw_activity,ClickHouse exception, code: 241, host: 10.58.10.243, port: 8123; Code: 241, e.displayText() = DB::Exception: Memory limit (total) exceeded: would use 3.33 GiB (attempt to allocate chunk of 4219140 bytes), maximum: 3.33 GiB (version 21.5.6.6 (official build))
ru.yandex.clickhouse.except.ClickHouseException: ClickHouse exception, code: 241, host: 10.58.10.243, port: 8123; Code: 241, e.displayText() = DB::Exception: Memory limit (total) exceeded: would use 3.33 GiB (attempt to allocate chunk of 4219140 bytes), maximum: 3.33 GiB (version 21.5.6.6 (official build))
at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.specify(ClickHouseExceptionSpecifier.java:58) ~[clickhouse-jdbc-0.2.4.jar:na]
at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.specify(ClickHouseExceptionSpecifier.java:28) ~[clickhouse-jdbc-0.2.4.jar:na]
at ru.yandex.clickhouse.ClickHouseStatementImpl.checkForErrorAndThrow(ClickHouseStatementImpl.java:875) ~[clickhouse-jdbc-0.2.4.jar:na]
at ru.yandex.clickhouse.ClickHouseStatementImpl.sendStream(ClickHouseStatementImpl.java:851) ~[clickhouse-jdbc-0.2.4.jar:na]
at ru.yandex.clickhouse.ClickHouseStatementImpl.sendStream(ClickHouseStatementImpl.java:824) ~[clickhouse-jdbc-0.2.4.jar:na]
at ru.yandex.clickhouse.ClickHouseStatementImpl.sendStream(ClickHouseStatementImpl.java:817) ~[clickhouse-jdbc-0.2.4.jar:na]
at ru.yandex.clickhouse.ClickHousePreparedStatementImpl.executeBatch(ClickHousePreparedStatementImpl.java:335) ~[clickhouse-jdbc-0.2.4.jar:na]
at ru.yandex.clickhouse.ClickHousePreparedStatementImpl.executeBatch(ClickHousePreparedStatementImpl.java:320) ~[clickhouse-jdbc-0.2.4.jar:na]
原因:批量写入时内存不够。 解决:调整扩大可用内存阈值。