housepower / ckman

This is a tool which used to manage and monitor ClickHouse database
Apache License 2.0
438 stars 108 forks source link

Update ck_rebalance.go #182

Closed 596192804 closed 2 years ago

596192804 commented 2 years ago

执行rebalance时报错: image 查看前文打印的日志: image image 可以看出是在217执行ALTER TABLE default.t_unstr_log_local FETCH PARTITION '20211201' FROM '/clickhouse/tables/cluster_2replica/default/t_unstr_log_local/1'这条SQL时报错。 现在去217执行这条SQL,复现报错: image 如果我们这时候先执行ALTER TABLE t_unstr_log_local DROP DETACHED PARTITION '20211201'; 再去跑ALTER TABLE default.t_unstr_log_local FETCH PARTITION '20211201' FROM '/clickhouse/tables/cluster_2replica/default/t_unstr_log_local/1',结果没有报错: image

596192804 commented 2 years ago

是的,要先在profile里面配置 allow_drop_detached =1

---Original--- From: "Zhichang @.> Date: Thu, Dec 16, 2021 19:52 PM To: @.>; Cc: @.**@.>; Subject: Re: [housepower/ckman] Update ck_rebalance.go (PR #182)

@yuzhichang commented on this pull request.

In business/ck_rebalance.go: > @@ -223,6 +223,7 @@ func (this CKRebalance) ExecutePlan(database string, tbl TblPartitions) (err e return fmt.Errorf("can't get connection: %s", dstHost) } dstQuires := []string{ +fmt.Sprintf("ALTER TABLE %s DROP DETACHED PARTITION '%s' ", tbl.Table, patt), fmt.Sprintf("ALTER TABLE %s FETCH PARTITION '%s' FROM '%s'", tbl.Table, patt, tbl.ZooPath),
这个SQL有失败的可能性: vm116 :) CREATE TABLE t(id Int64, val Float64) ENGINE=MergeTree() ORDER BY id PARTITION BY id%100; vm116 :) ALTER TABLE t DROP DETACHED PARTITION '12345'; Received exception from server (version 21.12.1): Code: 344. DB::Exception: Received from localhost:9900. DB::Exception: Cannot execute query: DROP DETACHED PART is disabled (see allow_drop_detached setting).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.