问题描述:

在两分片,每个分片两个副本的集群环境中:使用分布式DDL创建与删除ReplicatedMergeTree表都没问题。
问题出在:删除表后,再次创建此表,会报出表已存在,无法创建。
查询zk后,发现删除此表后,表的元数据还在zk中,要等10分钟左右,表的元数据才被清除。
如何在ch中删除表后,zk中的元数据也被同步删除?

https://github.com/ClickHouse/ClickHouse/issues/18382

 

处理办法:

This is a behavior related to Atomic database engine.
When a table in Atomic database been dropped it is not removed immediately but after 480s.

config.xml
<database_atomic_delay_before_drop_table_sec>480</database_atomic_delay_before_drop_table_sec>

https://github.com/ClickHouse/ClickHouse/blob/master/tests/config/config.d/database_atomic.xml

You can

  1. use ordinary database instead of atomic. create database ... Engine=Ordinary.
  2. use uniq ZK path using a new var. {uuid} /clickhouse/tables/{layer}-{shard}-{uuid}/streams.streams_apps_ext_log_test
  3. reduce database_atomic_delay_before_drop_table_sec = 0; & drop table ... sync(sync不需要,直接删除表即可)

 

<yandex>  

    <database_atomic_delay_before_drop_table_sec>60</database_atomic_delay_before_drop_table_sec>  

</yandex>

 

 posted on 2021-03-03 15:19  xibuhaohao  阅读(2102)  评论(0)    收藏  举报