clickhouse 在单表或单分区超过50GB时,将无法直接删除
1. 案例
模拟删除单表或单分区超过50GB时,删除报错的情况
1.1 一个表中超过50GB的分区
-- 删除分区的脚本如下
ALTER TABLE testdb.test DROP PARTITION (20220606,'12');
报错信息如下
Code: 359. DB::Exception: Received from localhost:9000. DB::Exception: Table or Partition in testdb.test was not dropped.
Reason:
1. Size (56.20 GB) is greater than max_[table/partition]_size_to_drop (50.00 GB)
2. File '/data/clickhouse/flags/force_drop_table' intended to force DROP doesn't exist
How to fix this:
1. Either increase (or set to zero) max_[table/partition]_size_to_drop in server config
2. Either create forcing file /data/clickhouse/flags/force_drop_table and make sure that ClickHouse has write permission for it.
Example:
sudo touch '/data/clickhouse/flags/force_drop_table' && sudo chmod 666 '/data/clickhouse/flags/force_drop_table'.
1.3 解决方法
报错信息中已给出解决方法:
1) 增大单表或单分区的可删除的大小
2) 通过执行脚本,强制删除
1.4 我们选择强制删除来解决
执行如下脚本
sudo touch '/data/clickhouse/flags/force_drop_table' && sudo chmod 666 '/data/clickhouse/flags/force_drop_table'
执行完毕以上脚本后即可删除分区