Loading...
Loading...
Track and diagnose ClickHouse ALTER UPDATE, ALTER DELETE, and other mutation operations. Use for stuck mutations and mutation performance issues.
npx skill4agent add altinity/skills altinity-expert-clickhouse-mutations-- Active merges on same table
select
database,
table,
is_mutation,
elapsed,
progress,
num_parts
from system.merges
where database = '{database}' and table = '{table}'-- Replication queue for same table
select
type,
create_time,
is_currently_executing,
num_tries,
last_exception
from system.replication_queue
where database = '{database}' and table = '{table}'
order by create_time
limit 20-- Part mutations status
select
name,
active,
mutation_version,
modification_time
from system.parts
where database = '{database}' and table = '{table}'
order by mutation_version desc
limit 30-- Find mutation_id first
select mutation_id, command from system.mutations
where database = '{database}' and table = '{table}' and not is_done;
-- Then kill it
-- KILL MUTATION WHERE database = '{database}' AND table = '{table}' AND mutation_id = '{mutation_id}';| Anti-Pattern | Problem | Solution |
|---|---|---|
| Frequent small UPDATEs | Creates many mutations | Batch updates together |
| DELETE without WHERE | Full table rewrite | Use TTL instead |
| UPDATE on high-cardinality column | Slow, lots of IO | Restructure data model |
| Many concurrent mutations | Queue builds up | Serialize mutations |
latest_fail_reason| Finding | Load Module | Reason |
|---|---|---|
| Mutation blocked by merge | | Merge backlog |
| Mutation OOM | | Memory limits |
| Mutation slow due to disk | | IO bottleneck |
| Replicated mutation stuck | | Replication issues |
| Setting | Notes |
|---|---|
| 0=async, 1=wait current replica, 2=wait all |
| Max concurrent mutations |
| Delay INSERTs threshold |
| Throw error threshold |