How Do I Delete the Copy Table of the ZooKeeper Node in a ClickHouse Cluster with Coupled Storage and Compute?
Symptom
When you connect a ClickHouse cluster and create a table, the ZooKeeper node does not get fully removed after you delete the table.

Possible Causes
The command for creating a table contains ON CLUSTER default_cluster. Therefore, a local table is created on each node.
Solutions
Delete the tables and stored data on other nodes.
- Create a database.
create database demo ON CLUSTER default_cluster;
- Create tables in the database.
use demo;
Create the test table.
CREATE TABLE demo.test ON CLUSTER default_cluster(`EventDate` DateTime, `id` UInt64)ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/default/test', '{replica}') PARTITION BY toYYYYMM(EventDate) ORDER BY id; - Delete the table.
drop table test SYNC;
- The following error message is displayed if a table with the same name as the deleted one is created:
┌─host──────────┬─port─┬─status─┬─error──────────────────────────────────────────────────────────────────────────────────────────────┬─num_hosts_remaining─┬─num_hosts_active─┐ │ 192.168.2.185 │ 9000 │ 57 │ Code: 57. DB::Exception: Table demo.test already exists. (TABLE_ALREADY_EXISTS) (version 22.3.2.1) │ 1 │ 1 │ └───────────────┴──────┴────────┴────────────────────────────────────────────────────────────────────────────────────────────────────┴─────────────────────┴──────────────────┘ ┌─host─────────┬─port─┬─status─┬─error─┬─num_hosts_remaining─┬─num_hosts_active─┐ │ 192.168.2.16 │ 9000 │ 0 │ │ 0 │ 0 │ └──────────────┴──────┴────────┴───────┴─────────────────────┴──────────────────┘
- Method 1: Run the following command to delete the tables and related data on each node:
drop table test ON CLUSTER default_cluster SYNC;
No error occurs if a table with the same name as the deleted one is created.
- Method 2: Delete the table on other nodes.
drop table test SYNC;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.

