Task output without --attempt can serve an older execution after a retry on another worker
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 50/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Domain
- backend-api-design, cli
Research direction
Start with _SQL_LATEST_EXECUTION and the output endpoint in server/orcaster_server/api/v1.py, then read the task execution query and schema in server/orcaster_server/schemas/api_v1.py. Trace the response through orcaster/internal/api/types.go and orcaster/cmd/task.go; the issue names server/tests/test_api_v1_tasks_output.py and the orcaster/cmd/testdata/task_get.golden files. Done means the default selects by execution time, task details expose execution IDs, and the documented CLI behavior and acceptance tests are updated.
Written by the indexing model from the issue text.
Description
Problem
GET /api/v1/tasks/{id}/output without attempt should serve the most recent execution of the task. orcaster/README.md:128-129 and the --attempt flag help (orcaster/cmd/task.go:214, "default: latest") promise this.
The server picks the execution with ORDER BY attempt_index DESC, id DESC LIMIT 1 (server/orcaster_server/api/v1.py:220-223, used at server/orcaster_server/api/v1.py:595-596). This does not give the most recent execution:
attempt_indexcounts per(task_id, worker_id), not per task. The claim insert computesMAX(attempt_index)for that pair, plus 1 (server/orcaster_server/api/poll.py:265-266). A retry that runs on another worker starts again at 1.- The tie-break is
id, a random UUID (server/orcaster_server/models.py:459-463). With two executions at index 1 on two workers, the pick has no relation to time. The existing test accepts either result (server/tests/test_api_v1_tasks_output.py:146-166). - If worker A ran attempts 1 and 2 and worker B then ran the newest execution at index 1, the default always serves the older execution on A.
So after a retry on another worker, orcaster task output <id> can show the log of an attempt that did not close the task.
The same detail route does not help the user reach the right execution. _SQL_TASK_EXECUTIONS does not select the execution id (server/orcaster_server/api/v1.py:207-215), TaskExecutionSummary has no id field (server/orcaster_server/schemas/api_v1.py:192-204), and the Go struct has none either (orcaster/internal/api/types.go:153-162). orcaster task output --execution <uuid> exists, but the CLI user has no way to learn the UUID from task get.
Steps to reproduce
- Start only worker A. Create a count-mode task with target 1 whose command fails. Wait until it is
failed. - Stop A, start worker B, and run
orcaster task retry <id>(any eligible worker). Wait until B finishes. - Run
orcaster task output <id>. When the UUID of the execution on A is larger than the one on B, the log of A is served. - Run
orcaster task get <id> --json. Both executions haveattempt_index1, and neither has an id.
For a deterministic test, seed the older execution with a larger UUID than the newer one.
Proposed change
- Pick the default execution by time:
ORDER BY assigned_at DESC NULLS LAST, id DESCin_SQL_LATEST_EXECUTION.idstays only as the last tie-break for equal timestamps. - Add the execution
idto_SQL_TASK_EXECUTIONS, toTaskExecutionSummaryand to the GoTaskExecutionSummary. Show it intask get(table and--json) and update the golden files (orcaster/cmd/testdata/task_get.golden). - Keep the meaning of
?attempt=N(per-worker index) in this issue. Document it in the endpoint docstring (server/orcaster_server/api/v1.py:584-585), the flag help andorcaster/README.md:--attempt Nis the N-th execution on one worker, and--execution <uuid>reaches any execution.
Compatibility
- Existing clients see a different default pick only for tasks whose executions ran on more than one worker. The response format does not change.
?attempt=Nkeeps its current meaning, so scripts that pass a per-worker index keep getting the same execution.- The new
idfield inGET /api/v1/tasks/{id}is additive. Older CLI binaries ignore it. - No database migration.
Acceptance criteria
- A server test seeds two executions of one task on two workers, both with
attempt_index1, gives the older one the larger UUID, and asserts that the default serves the newer one. - A server test seeds worker A with attempts 1 and 2, then worker B with attempt 1 as the newest, and asserts that the default serves the execution on B.
-
GET /api/v1/tasks/{id}returns anidfor each execution, andorcaster task getshows it. Golden files are updated. -
?attempt=Nreturns the same execution as before for existing data (test). - Existing clients keep working without changes: no field is removed or renamed, and
?attempt=Nkeeps its meaning. - The docstring, the flag help and
orcaster/README.mdstate the default rule and the meaning of--attempt. - CHANGELOG entry under Unreleased that names the new default pick.
Open questions
- Should
--attempt Nlater become a per-task number (the N-th execution of the task by time), matching theattempt_numberthattask retryprints (server/orcaster_server/api/admin_tasks.py:1013-1016,orcaster/cmd/task.go:1009)? That changes the meaning of a public query parameter and breaks clients that send a per-worker index. Keeping the current meaning, as proposed above, keeps existing deployments working. - The dashboard task detail may use its own "latest" rule. Should it follow the same rule here or in a follow-up?
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AInvirion/orcaster
-
enhancement P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
enhancement good first issue P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug P2 server
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
bug P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
enhancement P3 server
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
All issues in AInvirion/orcaster
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
daniel-ospina/tortoise#15308 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
difficulty:easy prio:low type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
NatronGitHub/Natron#2405 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Jstar269/nakagawa-recomp#3746 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day