Code: 420:索引列不能进行更新

:) ALTER TABLE test_update UPDATE event_date= '2021-06-15 00:00:00' WHERE event_date= '2021-06-14 16:00:00';

Received exception from server (version 21.1.2.15):
Code: 420. DB::Exception: Received from localhost:9000, ::1. DB::Exception: Cannot UPDATE key column `event_date`.

Code: 48:分布式表不能进行更新

Received exception from server (version 21.1.2.15):
Code: 48. DB::Exception: Received from localhost:9000, ::1. DB::Exception: Mutations are not supported by storage Distributed.

ALTER TABLE UPDATE/DELETE不支持分布式DDL,因此需要在分布式环境中手动在每个节点上local的进行更新/删除数据。

code:1002,jdbc error : ‘failed to respond’

2021-02-22 07:31:31,656 ERROR [main] execute clickhouse Query Error
ru.yandex.clickhouse.except.ClickHouseUnknownException: ClickHouse exception, code: 1002, host: xxxx, port: 8123; xxxx:8123 failed to respond
at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.getException(ClickHouseExceptionSpecifier.java:91)
at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.specify(ClickHouseExceptionSpecifier.java:55)
at ru.yandex.clickhouse.except.ClickHouseExceptionSpecifier.specify(ClickHouseExceptionSpecifier.java:24)
at ru.yandex.clickhouse.ClickHouseStatementImpl.getInputStream(ClickHouseStatementImpl.java:633)
at ru.yandex.clickhouse.ClickHouseStatementImpl.executeQuery(ClickHouseStatementImpl.java:117)
at ru.yandex.clickhouse.ClickHouseStatementImpl.executeQuery(ClickHouseStatementImpl.java:100)
at ru.yandex.clickhouse.ClickHouseStatementImpl.executeQuery(ClickHouseStatementImpl.java:95)
at ru.yandex.clickhouse.ClickHouseStatementImpl.executeQuery(ClickHouseStatementImpl.java:90)
at ru.yandex.clickhouse.ClickHousePreparedStatementImpl.executeQuery(ClickHousePreparedStatementImpl.java:110)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java)
 
Its root cause is that the JDBC underlying http connection header field keep-alive does not match between server and client side , always client utilizing a connection which server treat as closed .
And we have to create a retry mechanism to prevent this on app side , which is ugly . 
Release 0.2.6 solve this problem inner JDBC .See https://github.com/ClickHouse/clickhouse-jdbc/pull/515 for detail 


==========================
========解决方案 ↓ ========
升级clickhouse 版本到0.2.6 , 解决 JDBC client端和server端对 http connection , header `keep-alive` 不一致导致的问题
参考:
   https://github.com/ClickHouse/clickhouse-jdbc/issues/452
   https://github.com/ClickHouse/clickhouse-jdbc/pull/515
   

code: 159:read timeout,查询超时导致报错

解决:执行某些SQL很耗时导致最后报错读超时,这是因为clickhouse执行单次SQL的默认最大等待时间是30s,如果有比较耗时的SQL, 可以通过将JdbcURL的socket_timeout参数值设置的大一点来解决这个问题(注意这个参数的时间单位是毫秒,默认是30000)

code 62,Max query size exceeded:Select语句中使用in方式查询报错

在这里插入图片描述
解决方案:
这其实是因为查询语句特别的大造成的(我的in()里面有5万多个id号),而默认的max_query_size最大是256 KiB。打开/etc/clickhouse-server/user.d/newuser.xml(我新建的自己的newuser.xml配置文件),也可以是其他的users.xml,其中有两个部分,一部分是profiles和quotas。profiles保存了用户的配置,quotas保存了用户的配额。配额使您可以限制一段时间内的资源使用,或仅跟踪资源的使用。像max_query_size这种配置,就需要在profiles部分中配置。
在这里插入图片描述
注意这里的单位是bytes(字节),我这里设置了102410241024=1,073,741,824,就解决问题了
在这里插入图片描述
参考:
1.GitHub:Where should I specify max query size
2.clickhouse官方文档:max_query_size
3.clickhouse官方文档:Quotas
4.clickhouse官方文档:Settings

Code: 168, AST is too big,Maximum: 50000 (version 19.17.5.18 (official build))

解决了上面的max_query_size问题,再次执行语句,出现了AST太大了的报错:
在这里插入图片描述
解决方案:
在users.xml配置文件中添加相应配置

<max_ast_elements>10000000</max_ast_elements>
<max_expanded_ast_elements>10000000</max_expanded_ast_elements>

Code: 221,db::exception: no interserver io endpoint named…

复制副本数据时报错导致无法同步数据,直接在err.log日志文件看到的报错是:auto DB::StorageReplicatedMergeTree::processQueueEntry(ReplicatedMergeTreeQueue::SelectedEntryPtr)::(anonymous class)::operator()(DB::StorageReplicatedMergeTree::LogEntryPtr &) const: Poco::Exception. Code: 1000, e.code() = 111, Connection refused

出现这样的报错是因为没有指定interserver_http_host参数,clickhouse配置文件中关于对这个参数的描述我翻译过来大概意思就是这个参数是其他副本用于请求此服务器的主机名;如果未指定,则与“hostname-f”命令类似确定,此设置可用于将复制切换到另一个网络接口(服务器可以通过多个地址连接到多个网络)。

所以不指定该参数的话,服务器就会试图连接到自己,而对应的端口号未提供服务时就会报Connection refused这样的错误了

Code: 253, Replica /clickhouse/tables/XXX/XXX/replicas/dba07 already exists

出现这个错误的原因是建立副本表(ReplicatedMergeTree)的时候,如果数据库的引擎是Atomic,则在删除表之后马上重建会报这个错。删除的时候clickhouse是通过异步线程清除掉zookeeper上的数据的,立马新建的话可能异步线程还没开始执行,如果不想做其他操作的话,等一会再执行创建语句就不会报这个错了,也可以通过指定如下参数设置清除zookeeper上数据操作的延迟时间:

<!-- 修改参数 database_atomic_delay_before_drop_table_sec = 0 ,解决删除副本表立马重建会报错的问题 -->
<database_atomic_delay_before_drop_table_sec>0</database_atomic_delay_before_drop_table_sec>
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐