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: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-zeroerror. 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:
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 namedMergeMutate, so filter the error messages by thread name:
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:KILL MUTATION:
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 inlast_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
clusterAllReplicastable function, for exampleFROM clusterAllReplicas('default', system.part_log). system.part_logandsystem.text_logexist only if thepart_logandtext_logsections are present in the server configuration. The configuration file shipped with ClickHouse contains both.