FrankChen021 / bithon

An observability platform mainly for Java
Apache License 2.0
15 stars 5 forks source link

Update CK JDBC #528

Closed FrankChen021 closed 1 year ago

FrankChen021 commented 1 year ago

To gain performance improvement at the driver level

FrankChen021 commented 1 year ago

If the url is configured with decompress=1&compress=1, there will be exception thrown:

org.springframework.jdbc.BadSqlGrammarException: jOOQ; bad SQL grammar [insert into "bithon_event" ("timestamp", "appName", "instanceName", "type", "arguments") values (?, ?, ?, ?, ?)]; nested exception is java.sql.BatchUpdateException: Code: 246. DB::Exception: Can't decompress data: header is corrupt with decompressed block size 0. (CORRUPTED_DATA) (version 23.2.1.1)
, server ClickHouseNode [uri=http://localhost:8123/bithon, options={decompress=1,compress=1}]@-611786503
    at org.jooq_3.13.6.CLICKHOUSE.debug(Unknown Source) ~[na:na]
    at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:101) ~[spring-jdbc-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72) ~[spring-jdbc-5.2.15.RELEASE.jar:5.2.15.RELEASE]
    at org.springframework.boot.autoconfigure.jooq.JooqExceptionTranslator.translate(JooqExceptionTranslator.java:92) ~[spring-boot-autoconfigure-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.autoconfigure.jooq.JooqExceptionTranslator.handle(JooqExceptionTranslator.java:81) ~[spring-boot-autoconfigure-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.springframework.boot.autoconfigure.jooq.JooqExceptionTranslator.exception(JooqExceptionTranslator.java:55) ~[spring-boot-autoconfigure-2.3.12.RELEASE.jar:2.3.12.RELEASE]
    at org.jooq.impl.ExecuteListeners.exception(ExecuteListeners.java:274) ~[jooq-3.13.7.jar:na]
    at org.jooq.impl.BatchSingle.executePrepared(BatchSingle.java:260) ~[jooq-3.13.7.jar:na]
    at org.jooq.impl.BatchSingle.execute(BatchSingle.java:174) ~[jooq-3.13.7.jar:na]
    at org.bithon.server.storage.jdbc.event.EventJdbcWriter.write(EventJdbcWriter.java:69) ~[classes/:na]
    at org.bithon.server.sink.event.EventBatchWriter.flush(EventBatchWriter.java:103) ~[classes/:na]
    at org.bithon.server.sink.common.FixedDelayExecutor$Task.run(FixedDelayExecutor.java:69) ~[classes/:na]
    at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
Caused by: java.sql.BatchUpdateException: Code: 246. DB::Exception: Can't decompress data: header is corrupt with decompressed block size 0. (CORRUPTED_DATA) (version 23.2.1.1)
, server ClickHouseNode [uri=http://localhost:8123/bithon, options={decompress=1,compress=1}]@-611786503
    at com.clickhouse.jdbc.SqlExceptionUtils.batchUpdateError(SqlExceptionUtils.java:107) ~[clickhouse-jdbc-0.4.1-all.jar:clickhouse-jdbc 0.4.1 (revision: 4a6940b)]
    at com.clickhouse.jdbc.internal.InputBasedPreparedStatement.executeAny(InputBasedPreparedStatement.java:154) ~[clickhouse-jdbc-0.4.1-all.jar:clickhouse-jdbc 0.4.1 (revision: 4a6940b)]
    at com.clickhouse.jdbc.internal.AbstractPreparedStatement.executeLargeBatch(AbstractPreparedStatement.java:85) ~[clickhouse-jdbc-0.4.1-all.jar:clickhouse-jdbc 0.4.1 (revision: 4a6940b)]
    at com.clickhouse.jdbc.internal.ClickHouseStatementImpl.executeBatch(ClickHouseStatementImpl.java:622) ~[clickhouse-jdbc-0.4.1-all.jar:clickhouse-jdbc 0.4.1 (revision: 4a6940b)]
    at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeBatch(DruidPooledPreparedStatement.java:565) ~[druid-1.1.24.jar:1.1.24]
    at org.jooq.tools.jdbc.DefaultStatement.executeBatch(DefaultStatement.java:112) ~[jooq-3.13.7.jar:na]
    at org.jooq.impl.BatchSingle.executePrepared(BatchSingle.java:239) ~[jooq-3.13.7.jar:na]
    ... 5 common frames omitted
FrankChen021 commented 1 year ago

ClickHouse JDBC 4.x is buggy, remains at the latest 0.3.2

FrankChen021 commented 1 year ago

image

image

The improvement is significant