Skip to main content
A table accepts new mutations only while it has fewer than number_of_mutations_to_throw unfinished ones (1000 by default). After that, every ALTER TABLE ... UPDATE, ALTER TABLE ... DELETE, DELETE FROM and other mutating ALTER fails with TOO_MANY_MUTATIONS (code 692). Mutations are applied in the order they were created, so usually one mutation that can never finish is at the head of the queue and everything else waits behind it. Find that mutation in system.mutations, remove it with KILL MUTATION, and the rest of the queue is processed.

Example

To keep the example short, the limit is lowered to 5 for this table:
Changing the type from String to UInt32 rewrites the column with a mutation. The mutation fails on the value 'n/a', and the ALTER reports it (shortened here):
The statement failed, but two things have already happened: the column type in the table definition is now UInt32, and the mutation stays in the queue and is retried again and again. With alter_sync = 0 the ALTER does not wait for the mutation and returns without any error, which makes the problem harder to notice. Reading the column now fails, because the stored strings are converted on the fly:
Every further mutation is queued behind the failing one, until the limit is reached:
The last statement is rejected. So is a lightweight DELETE FROM readings WHERE id = 105, and so is an ALTER TABLE readings MODIFY COLUMN value String that tries to undo the type change.

Find the mutation that blocks the queue

Look at the oldest unfinished mutation that has a failure reason:
The mutations queued behind it can show the same latest_fail_reason, because a part has to pass the earlier mutation first. The oldest one is the cause. If no unfinished mutation has a failure reason, the queue is not blocked by an error: mutations are submitted faster than the table applies them. See Other causes.

Fix it

Kill the blocking mutation only:
KILL MUTATION removes the mutation from the queue, but it does not undo a schema change. After a failed MODIFY COLUMN, the table definition still has the new type and SELECT still fails, so change the column back to the type that the data has:
Now the remaining mutations run without further action. In the example, the queued DELETE WHERE id = 100 has been applied:
If the blocking mutation is an UPDATE or DELETE with an expression that fails, killing it is enough: there is no schema change to undo. KILL MUTATION WHERE database = ... AND table = ... without a mutation_id kills all unfinished mutations of the table. Use it only if you are ready to submit the other mutations again. To do the type change properly, first make the data convertible, then change the type:

Other causes

  • Many small mutations. An application that sends one ALTER TABLE ... UPDATE or DELETE per row or per event can fill the queue even though each mutation succeeds. Combine the changes into fewer statements. See How do I view the number of active or queued mutations? to watch the queue.
  • Nullable to non-Nullable. Before ClickHouse 25.12, MODIFY COLUMN from a Nullable type to a non-Nullable type got stuck in the same way when the column contained NULL. Since 25.12 such an ALTER is rejected unless it has a DEFAULT expression, and NULL values are replaced with that default, for example ALTER TABLE t MODIFY COLUMN c String DEFAULT ''.

About the limits

Both are MergeTree settings that you can change for a table with ALTER TABLE ... MODIFY SETTING. Raising them does not make the queue shorter: it only postpones the error, so fix the cause first. For other ways to find failing mutations, see How to find failed merges and mutations.