Skip to content

fix: store and cancel new tasks at backends #275

Closed

Description

@uniqueg

Problem

TaskRuns.create_task reads the state of a new task from its backend (e.g., QUEUED) but sets it only on the local object. _update_doc_in_db then replaces that object with the stored document, which still has the state UNKNOWN, and writes it back. The task stays UNKNOWN until a Celery worker starts tracking it, which can take long while the workers are busy, and forever while they are down.

UNKNOWN is not cancelable, so POST /tasks/{id}:cancel returns 200 {} without calling the backend, and the task keeps running there. docs/api.md promises cancelling for any task that has not finished.

tests/ga4gh/tes/test_server.py sets the state to QUEUED by hand before cancelling, which hides the bug.

Found in the pre-release review of v0.3.0 (finding 2).

Proposed change

  • Store the state that the backend reported when the task is stored with its backend.
  • Cancel unfinished tasks (also UNKNOWN ones) at their backend if they have a remote identifier (tes_endpoint.task_id); for unfinished tasks without one, return an error (409) instead of a silent 200.
  • Test cancelling right after creation, without setting the state by hand.

Activity

  1. added
    priority: high
    status: in progress
    type: bug
    workload: hours
    on Oct 23, 2026
  2. removed
    status: in progress
    on Oct 24, 2026
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

    priority: hightype: bugworkload: hours

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions