fix alter table ttl error when this table has light weight delete mask file (_row_exists.bin)

After  applying light weight delete to MergeTree table,  a delete mask file (_row_exists.bin) will appears in the wide part directory.  Then we execute "ALTER TABLE xxxxxx  MODIFY TTL xxxx" to this table, clickhouse will report error in log message:   "NOT_FOUND_COLUMN_IN_BLOCK, Not found column _row_exists  in block".   
The root cause of this bug is that:  in MutationsInterpreter::prepare(), when constructing the select columns,  it does not include the system columns, but only physic columns (not include _row_exists.bin).  however the output block of the execute pipeline contains _row_exists column, then error occurs.

this bug is severe, because mutate TTL will continuously to execute, never end. the only workaround is to truncate the whole table.

the fix is to return all columns including row_exists when executing alter table TTL query
This commit is contained in:
Mingliang Pan 2023-01-06 10:58:34 +08:00 committed by GitHub
parent c1f6555b32
commit c98e52e9ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -656,6 +656,12 @@ ASTPtr MutationsInterpreter::prepare(bool dry_run)
}
else if (command.type == MutationCommand::MATERIALIZE_TTL)
{
if (auto part_storage = dynamic_pointer_cast<DB::StorageFromMergeTreeDataPart>(storage))
{
if (part_storage->hasLightweightDeletedMask())
return_all_columns = true;
}
mutation_kind.set(MutationKind::MUTATE_OTHER);
if (materialize_ttl_recalculate_only)
{