Skip to content

Celery task update_storage_usage_cache has no time_limit — worker may hang indefinitely #11816

Description

@Joaquinriosheredia

Hi,

While analyzing the codebase with python-vibe-guard, I found a potential
issue in api/caching/tasks.py line 117.

The Celery task update_storage_usage_cache has no time_limit or
soft_time_limit defined:

@app.task(max_retries=5, default_retry_delay=10)
def update_storage_usage_cache(target_id, target_guid, per_page=...):
    storage_usage_total = compute_storage_usage_total(...)

compute_storage_usage_total executes a paginated SQL query over file
versions. If the query blocks (database lock, large table, index contention),
the Celery worker will hang indefinitely — there is no timeout mechanism
to recover it.

Suggested fix:

@app.task(
    max_retries=5,
    default_retry_delay=10,
    soft_time_limit=270,
    time_limit=300,
)
def update_storage_usage_cache(...):

With a SoftTimeLimitExceeded handler to log which target_guid was
being processed when the timeout fired.

Tool used: python-vibe-guard
AST-based runtime anti-pattern scanner validated on 902 real repositories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions