Blog

When did that mutation finish?

system.mutations told you when a mutation started but not when it ended. I asked for finish_time; it shipped in 26.8 after a first attempt was reworked to avoid persistent state.

Source: github.com

system.mutations has create_time, parts_to_do, is_done and latest_fail_time, but not when a mutation ended, so “how long did last night’s mutations take?” had no answer in SQL. I asked for a finish_time DateTime column.

It was labelled easy task, and two PRs tried it. The first, #105255, closed unmerged after a contributor, ZelvaMan, asked the deciding question: must it survive a restart? Persisting means a file-format or Keeper change with upgrade and cleanup questions. The second, #113474 by nikitamikhaylov, reworked it to add no persistent state, merged 2026-08-20 and closed the issue; it shipped in 26.8. Semantics:

  • 0 means not finished, or completion time unknown (entries loaded at startup, parts removed by DROP PARTITION).
  • Non-replicated MergeTree stamps the time in memory when completion is observed.
  • For ReplicatedMergeTree the value is per replica: the modification time of the replica’s mutation_pointer znode. For a cluster-wide time use max(finish_time) per mutation_id.

The column is absent on 26.4, the binary I have here, and present on 26.8 (not run here, so treat the query as intended usage):

SELECT mutation_id, command,
       dateDiff('second', create_time, finish_time) AS seconds
FROM system.mutations
WHERE is_done AND finish_time != toDateTime(0)
ORDER BY seconds DESC LIMIT 10;

The finish_time != 0 filter matters: after a restart old mutations honestly report unknown. See watch mutation progress.

feature-requestsystem-tablesmutations

Discussion

Comments live in GitHub Discussions. Sign in with GitHub to join in.