Skip to content

get_tasks_for_run() fetches all tasks without LIMIT when called from cache prefetch #473

@Aryan95614

Description

@Aryan95614

get_tasks_for_run() in services/ui_backend_service/data/db/tables/task.py (line 304) calls find_records() without passing a limit, so it defaults to 0 which means no LIMIT clause in the SQL. With enable_joins=True it fires the lateral joins against metadata_v3 and artifact_v3 for every task in the run.

The API layer is fine -- endpoints go through pagination_query() which caps at 1000. But this method gets called from the cache prefetch path in data/cache/store.py (line 221), which bypasses the API layer entirely.

For a run with a big foreach (hundreds of tasks), this is one unbounded query with lateral joins for each task row. Not sure how often the prefetch actually fires for large runs but it seems like it could be a problem at scale.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions