Skip to content

Busy-waiting in SortPreservingMergeStream #16321

Closed

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

Activity

  1. pepijnve commented on Jun 7, 2025

    @pepijnve
    ContributorAuthor

    Investigating, but help appreciated.

  2. pepijnve commented on Jun 7, 2025

    @pepijnve
    ContributorAuthor

    A closer look shows I might be completely mistaken. Will close if irrelevant. Nope, not a case of PEBKAC after all. I've refined the reproduction scenario.

  3. pepijnve commented on Jun 8, 2025

    @pepijnve
    ContributorAuthor

    Just to have a hyperlink between the issues: as far as I can tell the behavior was introduced by #12302 to resolve #12300.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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