You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
fix: reread tasks before refusing to cancel them