Repository navigation
fix(task): stop appending the task id to the results key twice (#715) - #717
Merged
Merged
Conversation
task status reported every finished task as "running" and --wait polled to TTL and exited 1 on tasks that had succeeded in seconds. EffectiveResultsPrefix already ends in the task id. completionKey appended it again. So the wrapper wrote — and spawn PRINTED — tasks/<task_id>/completion.json while the reader fetched tasks/<task_id>/<task_id>/completion.json which 404s, and the read path correctly reads a 404 as "no record yet". Verified against the reporter's own bucket: head-object on the first key returns 337 bytes, on the second a 404. All three of their affected tasks now read `completed`, exit 0, with matching run_id. Present since v0.117.0, not v0.121.0 as reported: both halves — the prefix gaining the task id and these builders appending it — arrived in the same commit (#658), so neither looked wrong on its own. That also explains why records written by older spawn versions were unreadable: the reader changed, not the writer. The second defect the report could not see: clearStaleCompletion uses the same builders, so the pre-launch clear had been deleting keys that do not exist. Deleting an absent key is a no-op success in S3, so it reported success and removed nothing — #608's stale-record guard has been inert since v0.117.0. Fixing only the read would have resurrected that bug, where a previous attempt's record answers this run. The task id is no longer a parameter to any of these builders, and clearStaleCompletion lost its vestigial taskID too. That parameter was the actual hazard: two plausible things to pass, no compiler or vet complaint for passing the wrong one. An existing test caught my first attempt leaving it in place, which is the best argument for removing it rather than documenting it. The gate is a ROUND-TRIP: the key the reader computes must equal the URI the writer prints, across the default bucket, a custom results_prefix, a bare bucket, and a trailing slash. Asserting completionKey returns some expected string would not have caught this, because the builder was self-consistent — only comparing it against the writer's own path reveals the disagreement. Confirmed to fail against the shipped behaviour, printing both URIs side by side. Also updated TestClearStaleCompletion_DeletesBothKeys, which passed a bare "tasks" prefix and so encoded a calling convention no caller used — the ambiguity that produced this bug in the first place.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #715.
Your diagnosis was exactly right — read path, not write path — and the cause is one character of path too many.
The bug
EffectiveResultsPrefixalready ends in the task id.completionKeyappended it again:The second 404s, and the read path correctly treats a 404 as "no record yet" — so a finished task reads as
runningforever. Confirmed against your bucket:All three of your affected tasks now read correctly:
One correction: it is not a 0.121.0 regression
It has been broken since v0.117.0. Both halves —
EffectiveResultsPrefixgaining the task id, and these builders appending it — arrived in the same commit,528e038(#658). Neither looked wrong on its own, and no test referenced the key builders at all.That also explains the detail you flagged as evidence of a regression: records written by older spawn versions are unreadable now because the reader changed, not the writer. Your note that
--waitworked in earlier sessions is consistent — those were pre-0.117.0.A second defect, which your report could not have shown
clearStaleCompletionuses the same builders. So the pre-launch clear has been deleting keys that do not exist — and since deleting an absent key is a no-op success in S3, it reported success and removed nothing. #608's stale-record guard has been inert since v0.117.0.Fixing only the read path would have resurrected #608: a previous attempt's record sitting at the shared key answering the current run. That is the "stale-record-on-same-task_id-reuse quirk" in your notes, and it would have come back the moment reads started working again. Both are fixed together.
Why the parameter is gone rather than documented
The task id is no longer a parameter to
completionKey,exitCodeKey,staleResultKeysorclearStaleCompletion. That parameter was the hazard itself: two plausible things to pass (tasksortasks/<id>), with no compiler orgo vetcomplaint for choosing wrong.Worth admitting how I know: my first attempt left the vestigial
taskIDonclearStaleCompletion, and an existing test caught it — it started deletingtasks/completion.json, dropping the id entirely. Which is a better argument for deleting the parameter than any comment I could write.That same test,
TestClearStaleCompletion_DeletesBothKeys, was passing a bare"tasks"prefix — encoding a calling convention no production caller used. It is updated to match reality.The gate is a round-trip
The writer never builds a key; it formats the resolved prefix directly:
So the printed URI is the contract. The new test derives the key both ways and asserts they name the same object, across the default bucket, a custom
results_prefix, a bares3://bucket, and a trailing slash.A test asserting
completionKey()returns some expected string would not have caught this — the builder was perfectly self-consistent. Only comparing it against the writer's own path reveals the disagreement. Verified to fail against the shipped behaviour, printing both URIs side by side.On your workaround
Polling the output bucket for the declared outputs rather than trusting the record is strictly better and I would keep doing it. It checks artifacts instead of a status field, which is the same reasoning behind this project's "exit 0 is not evidence" rule — and it is what let you catch this at all. The fix makes
--waitusable again; it does not make it more trustworthy than checking the outputs.