Troubleshooting Tip: ClickHouse Provision error: ClickHouse DDL failure: One of the entries is already present in ClickHouse-Keeper registry
Description
This article provides a method to fix ClickHouse DDL failure during testing and deployment of a ClickHouse configuration.
Scope
FortiSIEM.
Solution
During the deployment of a ClickHouse cluster, users may encounter the following error: 'Failed: ClickHouse provision error: ClickHouse DDL Failure: One of the entries is already present in ClickHouse-Keeper registry. This could happen if a previous instance with the same is not cleaned up from the ClickHouse Keeper registry. To delete the offending entry, follow Step 8 in the Deleting from ClickHouse Cluster section in the user guide: Advanced ClickHouse Config'.

This error occurs due to metadata in the ClickHouse keeper mismatching with the configuration in the GUI. Cleanup is required.
- Check the metadata of shard in the ClickHouse Keeper.
/opt/zookeeper/bin/zkCli.sh
ls /clickhouse/tables
Output example:
[zk: localhost:2181(CONNECTED) 0] ls /clickhouse/tables
[1]
Notes:
[1] indicates the shard number shown in the GUI, as depicted in the following screenshot:

If [1 , 2] shows as the output of 'ls /clickhouse/tables', the issue is a mismatch with the GUI and it is necessary to remove shard 2 from the ClickHouse Keeper metadata with the following command:
deleteall /clickhouse/tables/2
- Check the metadata of replica in ClickHouseKeeper.
/opt/zookeeper/bin/zkCli.sh
ls /clickhouse/table/<shard number>/fsiem.events/replicas/
ls /clickhouse/table/<shard number>/fsiem.summary/replicas/
ls /clickhouse/table/<shard number>/fsiem.mv_events/replicas/
Examples:
ls /clickhouse/tables/1/fsiem.events/replicas
ls /clickhouse/tables/1/fsiem.summary/replicas
ls /clickhouse/tables/1/fsiem.mv_events/replicas
Notes:
The output needs to be the same with the number of Replicas in the GUI:

If there are extra replicas showing in the output as in the example below, they need to be removed:
ls /clickhouse/tables/1/fsiem.events/replicas
[ 1 , 2]
deleteall /clickhouse/tables/1/fsiem.events/replicas/2
Notes:
The Replica ID may not appear the same as it does in the GUI. The user may validate the data by logging in to each replica and running the following command:
clickhouse-client -q "select database, table,zookeeper_path, replica_is_active from system.replicas format Vertical"
The 'replica_is_active:' column will show the ID. Check with the ID shown in the zookeeper before deleting. If the wrong Replica ID is deleted, it can be recovered by Testing and deploying via the GUI again.
- After the metadata is cleaned, the user may proceed to run GUI -> Admin -> Settings -> ClickHouse Config -> Test and deploy again.
Related document:
Technical Tip: How to remove a mounted disk from a ClickHouse server