2023年12月8日发(作者:)

ClickHouse(十六)异常处理总结

1. DB::Exception: Nested type Array(String) cannot be inside Nullable type (version 20.4.6.53 (official build))

原因:字段类型是Nullable(String),在使用一些字符串函数如splitByString,他们对Nullable类型是不支持的,需要转成String。

解决:使用cast强转一下字段类型就行:

select splitByString(',',cast(col as String)) col from test

2. DB::Exception: Cannot convert NULL value to non-Nullable type: while converting source column second_channel to

destination column second_channel (version 20.4.6.53 (official build))

原因:字段类型是非空类型,insert null值到非空字段second_channel会报错。

解决:可以将非空类型改成Nullable(String),但是要注意Nullable字段不允许用于order by。

3. DB::Exception: Memory limit (total) exceeded: would use 113.20 GiB (attempt to allocate chunk of 134200512 bytes),

maximum: 113.14 GiB: While executing CreatingSetsTransform. (version 20.4.6.53 (official build))

原因:单次查询出来的数据量,大于单台机器的剩余内存。

解决:可以将查询范围缩小,比如添加查询条件对查询结果取余,也可以清理或者添加物理机内存

4. DB::Exception: MySQL database engine does not support create table. for tables that were detach or dropped before,

you can use attach to add them back to the MySQL database (version 20.4.6.53 (official build))

5. ClickHouse exception, code: 209, host: 10.10.130.139, port: 8123; Code: 209, yText() = DB::NetException:

Timeout exceeded while reading from socket (10.10.161.50:9000): while receiving packet from

dc_clickhouse27:9000: While executing Remote (version 21.3.15.4 (official build))

6. Cause: ouseUnknownException: ClickHouse exception, code: 1002, host:

10.10.130.139, port: 8123; ClickHouse response without column names

7. Cause: ouseUnknownException: ClickHouse exception, code: 1002, host:

10.10.130.139, port: 8123; Connection reset

8. yText() = DB::Exception: Table columns structure in ZooKeeper is different from local table structure (version

20.12.3.3 (official build))

原因:Replicated(副本)表删表重建,但zk中表结构删除操作是异步的,默认为五分钟

解决:重启该节点的ck,或者选择等待几分钟内

9. yText() = DB::Exception: Different number of columns in UNION ALL elements

原因:使用union all的两个查询语句查出不同数量的列字段

10. yText() = DB::ErrnoException: Cannot unlink file /srv/BigData/data2/clickhouse/store/1ef/1ef6a386-24b2-

4ce0-8ebd-e78a61638fb3/format_, errno: 2, strerror: No such file or directory (version 21.3.4.25)