ALTER MODIFY COLUMN is stuck, the column is inaccessible.
Problem
You’ve created a table in ClickHouse with the following structure:
You populated the table with some data:
Next, you attempted to change the column type using this query:
However, the operation failed, and you encountered an error when inspecting the system.mutations table:
The mutation result showed an error indicating that the value ‘key_c’ was not recognized in the Enum8 definition:
Now, when trying to query the column, ClickHouse returns an exception and the column becomes inaccessible:
This query results in:
Root Cause
The failure occurred because the Enum8 type only allows for predefined values. Since ‘key_c’ wasn’t included in the definition, the mutation failed and left the table in an inconsistent state.
Solution
- Identify and Terminate the Stuck Mutation First, you need to locate the mutation that’s stuck in an incomplete state.
Once you’ve identified the mutation, terminate it using:
This will stop the operation and allow you to revert the changes.
- Revert the Column Type Next, revert the column back to its original type, which was String, to restore the table’s accessibility:
- Verify the Column is Accessible Again To ensure the column is functioning normally, run a simple query to verify its data:
- Apply the Correct Column Modification Now that the column is accessible, you can safely reapply the ALTER query, but this time include all the required enum values:
- Monitor Progress You can monitor the progress of the column modification using the system.mutations or system.parts_columns tables to ensure everything proceeds as expected:
To track mutation progress:
To review the column’s active parts: