Migrate Replicated table

361 views
Skip to first unread message

Yegor Andreenko

unread,
Nov 16, 2016, 3:44:35 AM11/16/16
to ClickHouse
I have table `events` = ReplicatedMergeTree('.../events'), and to fix an issue I have to migrate it to another type of Replicated table, that is `events` = ReplicatedReplacingMergeTree('../events').

How can I accomplish this without downtime? The problem is to change zookeeper path of new table.
So I assume following scenario:

create table events_temp = ReplicatedReplacingMergeTree('../events_repl')   (because you couldn't create table with different schema under the same zookeeper_path)
insert into events_temp select * from events;
rename table events to events_old;
rename table events_repl to events;

update table events set zookeeper_path = '
../events'

man...@gmail.com

unread,
Nov 16, 2016, 4:12:24 PM11/16/16
to ClickHouse
You cannot change path for a table in ZooKeeper without downtime.

It is very difficult to implement renaming (moving) of whole subtree in ZK. ZooKeeper itself doesn't support that kind of operation.
It is very hard to do it manually, considering existence of ephemeral nodes, sequential nodes; limit on maximum transaction size and so on.

Better to just use new path in ZooKeeper for new table and don't care that it now does not correspond to table name.

Yegor Andreenko

unread,
Nov 16, 2016, 5:59:28 PM11/16/16
to ClickHouse
thanks
Reply all
Reply to author
Forward
0 new messages