一、分布式ddl 阻塞、超時(shí)
現(xiàn)象
在clickhouse 集群的操作中,如果同時(shí)執(zhí)行一些重量級變更語句,往往會引起阻塞。 一般是由于節(jié)點(diǎn)堆積過多耗時(shí)的ddl。然后拋出如下異常
ru.yandex.clickhouse.except.ClickHouseException: ClickHouse exception, code: 159, host: 127.0.0.1, port: 8123; Code: 159, e.displayText() =
DB::Exception: Watching task /clickhouse/task_queue/ddl/query-0000000318 is executing longer than distributed_ddl_task_timeout (=180) seconds.
驗(yàn)證方法
1.查詢zookeeper的隊(duì)列數(shù),節(jié)點(diǎn)完成情況。
2.查詢mutations表,改更較重操作一般會在這個(gè)表記錄。
select FQDN() as node,
database,
table,
mutation_id,
create_time,
command,
is_done,
parts_to_do
FROM clusterAllReplicas('default_cluster', system.mutations)
WHERE is_done = 0;
解決方案
先看能不能是kill MUTATION ,確定一下是不是所有節(jié)點(diǎn)里都KILL了,如果所有節(jié)點(diǎn)都確定KILL了這個(gè)隊(duì)列還堵在那就只能刪ZK。
KILL MUTATION on cluster default_cluster WHERE database = 'default' AND table = 'table';
二、副本同步阻塞
現(xiàn)象
寫入副本表后,查詢數(shù)據(jù)量不一致或是很長時(shí)間才能一致。例如原表8968w, 寫入sql都已經(jīng)執(zhí)行完成,查詢只有6629w。集群沒有阻塞時(shí)會直接查詢到全量數(shù)據(jù)。
CREATE TABLE tmp.dwm_we_search_query_ad_data_v5_copy_20230815_local (
`f000_date` Nullable(Date),
`row_key` Int64,
`day_` Nullable(String),
`hour_` Nullable(String),
`position_id` String,
`query` String,
`aid` Int64,
`advertiser_id` String,
`query_classify_res` Nullable(Int64),
`imp_fail_cnt` Nullable(Int64),
`imp_pv` Nullable(Int64)
)
ENGINE = ReplicatedReplacingMergeTree('/clickhouse/default_cluster/tables/{shard}/tmp/dwm_we_search_query_ad_data_v5_copy_20230815_local', '{replica}')
PARTITION BY ds_
ORDER BY (ds_, position_id,query,aid,advertiser_id,row_key)
SETTINGS index_granularity = 8192
驗(yàn)證
查詢 system.replication_queue 表的數(shù)量,如果記錄很多,說明正在同步的任務(wù)多,數(shù)據(jù)達(dá)到一致的延遲大。文章來源:http://www.zghlxwxcb.cn/news/detail-665369.html
-- 查詢同步隊(duì)列數(shù)
SELECT count() FROM system.replication_queue;
-- 查詢同步表詳情
SELECT * FROM system.replication_queue LIMIT 1 FORMAT Vertical;
解決方案
首先確認(rèn)同步隊(duì)列中的表是否正常業(yè)務(wù)需要的,集群的io是否正常。 如果確實(shí)有大量的寫入業(yè)務(wù),就需要調(diào)整副本并行的線程大小replicated_max_parallel_fetches_for_host, 如果發(fā)現(xiàn)大量沒用/測試 的表在同步,可刪除,這也是快速解決問題的方案。文章來源地址http://www.zghlxwxcb.cn/news/detail-665369.html
到了這里,關(guān)于clickhouse(十四、分布式DDL阻塞及同步阻塞問題)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!