Skip to content

Filter operator does not return constant column for filter column, which may crash TiFlash when sort spill is triggered. #9999

@windtalker

Description

@windtalker

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Filter operator should always return constant 1 column for filter column, but in current implementation, it may not be true if a block with all rows be kept:

if (filtered_rows == rows)
{
/// Replace the column with the filter by a constant.
auto filter_column = block.safeGetByPosition(filter_column_position);
filter_column.column = filter_column.type->createColumnConst(filtered_rows, static_cast<UInt64>(1));
/// No need to touch the rest of the columns.
return true;
}

I believe it is just a typo because the comments shows "Replace the column with the filter by a constant."

Filter not return constant column for filter column may make sort spill crash because in sort operator, it will remove constant column:

SortHelper::removeConstantsFromBlock(block);

If some block returned by filter operator contants constant column while others does not contain constant column, the block in sorted_blocks will have different schemas, which will cause a series of troubles, the worst case is make TiFlash crash.

2. What did you expect to see? (Required)

3. What did you see instead (Required)

4. What is your TiFlash version? (Required)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions