-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Hi team,
I’m using mysql_ch_replicator to replicate data from MySQL to ClickHouse.
When I apply a migration to MySQL that includes ALTER TABLE ADD COLUMN enable_deadline, the replicator crashes with the following error from ClickHouse:
clickhouse_connect.driver.exceptions.DatabaseError: HTTPDriver for http://clickhouse:8123 received ClickHouse error code 15
Code: 15. DB::Exception: Cannot add column `enable_deadline`: column with this name already exists. (DUPLICATE_COLUMN)
Steps to Reproduce
- Run the replicator with a MySQL table already replicated to ClickHouse.
- Apply a MySQL migration:
ALTER TABLE your_table ADD COLUMN enable_deadline TINYINT(1) DEFAULT 0;
- Replicator crashes with the error above.
What I’ve Tried
- I manually deleted the enable_deadline column from ClickHouse.
- After re-running the migration and restarting the replicator, the column gets re-added, but the replicator still crashes with the same error.
- It seems the replicator does not check if a column already exists before generating and executing the ALTER TABLE ADD COLUMN statement in ClickHouse.
Expected Behavior:
The replicator should check if the column already exists in ClickHouse and skip the ADD COLUMN statement if it does, or use a safe mechanism to avoid duplicate column errors.
Suggested Fix:
Before issuing an ALTER TABLE ADD COLUMN in ClickHouse, the replicator should:
- Query the system.columns table to verify whether the column exists.
- Skip or log a warning instead of throwing a fatal exception.
Thanks for the great work on the project!
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working