Skip to content

Busy-waiting in SortPreservingMergeStream #16321

@pepijnve

Description

@pepijnve

Describe the bug

When running a query like select a from annotated_data_infinite2 order by b desc limit 10, a SortPreservingMergeStream is created that merge sorts the presorted partitions. During the initial sorting phase of the query, the query execution will continuously hit

where the stream wakes the current task for rescheduling. Since all the input streams will be pending for quite some time during the sort of a large data the execution ends up in a busy-waiting loop.

I believe this was introduced in f2a8b07. It's not clear to me why the self wake was added.

To Reproduce

Expected behavior

  • No busy-waiting during query execution

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions