Skip to main content
Merges and mutations run in the background, not as queries, so their errors are not in system.query_log. Look for them in these places: A failed merge or mutation is retried, so one problem usually produces the same error many times.

Example setup

This mutation can never finish, because one of the values is not a number:
The ALTER returns without an error, because the mutation is executed in the background. The log tables used below are written with a delay of a few seconds. To see fresh rows at once, run SYSTEM FLUSH LOGS first.

system.part_log

Failed attempts have a non-zero error. The event type is MergeParts for a merge and MutatePart for a mutation:
part_name is the part that the operation tried to create, and merged_from lists its source parts. The exception column holds the full message with the stack trace, so the query cuts it. To get an overview of what is failing and how often, group the same rows:
A merge that was cancelled, for example by SYSTEM STOP MERGES, is recorded with the error ABORTED. That is not a failure.

system.text_log

The background threads that run merges and mutations are named MergeMutate, so filter the error messages by thread name:
The identifier in braces is the UUID of the table followed by the name of the part. Select the whole message to read the stack trace.

system.mutations

For mutations, the quickest check is the list of unfinished mutations that have failed at least once:
A mutation that cannot succeed keeps being retried and blocks the mutations queued after it. Remove it with KILL MUTATION:
See also How to resolve the TOO_MANY_MUTATIONS error.

system.replication_queue

For replicated tables, merges and mutations are entries of the replication queue. A failing entry shows its last error in last_exception and the number of attempts in num_tries:

Notes

  • All these tables describe the server that runs the query. On a cluster, or in ClickHouse Cloud, read them from every replica with the clusterAllReplicas table function, for example FROM clusterAllReplicas('default', system.part_log).
  • system.part_log and system.text_log exist only if the part_log and text_log sections are present in the server configuration. The configuration file shipped with ClickHouse contains both.