Repository navigation
Description
Summary
The Prepare Download Artifacts task can continue preparing an artifact after every download referencing it has been deleted. If its output file subsequently disappears, recovery queues another encode without checking whether any download still needs it.
This was observed in a Docker deployment where PostgreSQL retained the artifact record but the artifact output directory was not persistently mounted. Container recreation removed the generated file, and the surviving database record caused recovery to prepare it again.
Retained logs show six missing-output requeue events for the same artifact. During investigation, its encoder was actively producing output despite there being no associated download records.
The operation does not require administrator privileges. Any user permitted to create the relevant download can encounter this behavior.
User workflow
- A user requests a download requiring preparation.
- The server creates a download record and a shared artifact record.
- The user deletes the download.
- No other download references the artifact.
- Artifact preparation continues, or a later missing-output recovery starts it again.
Deleting the download removes the user-visible entry, but does not remove the artifact’s eligibility for background preparation.
Expected behavior
- Queued preparation should not begin when no download requires the artifact.
- Deleting the last consumer during preparation should follow an explicit cancellation or completion policy.
- Missing output should be regenerated only when a valid consumer requires it.
- Deleting one consumer must preserve preparation needed by other downloads sharing the artifact.
- Retaining an existing artifact for possible cache reuse should not require rebuilding it whenever its bytes disappear.
- Recovery, cleanup, and new download creation must coordinate so a concurrent consumer cannot lose valid work.
Actual behavior
- Download deletion leaves the artifact record independently eligible for processing.
- The worker claims queued artifacts without checking for remaining download references.
- Missing-output recovery requeues ready artifacts without checking for consumers.
- The orphan sweep only considers ready artifacts unused for 30 days.
- Recovery and queue processing occur before the task’s cleanup phase.
- Successful preparation updates
last_used_at, refreshing the timestamp used by orphan retention. - Missing-output requeue resets the attempt counter, so it does not represent lifetime preparation attempts.
Environment and scope
The observed environment used:
- Docker for the application.
- PostgreSQL for durable download and artifact state.
- The application artifact directory
/tmp/silo-download-artifacts, without a persistent mount covering it. - Container recreation during application updates.
No particular media title, user role, or administrator-only action is required by the identified mechanism.
The observed artifact used the audio_v2_running lifecycle state and was performing video and audio preparation. That status name does not mean the operation was audio-only.
Source analysis was performed on branch apiv2 at:
8771e3a02e71575e562c1eb10e9662e60f63c18e
The exact source commit embedded in the inspected container was not verified. Runtime observations and source findings are separated below.
Observed timeline
All timestamps are UTC. Resource identifiers, media details, account information, and deployment identifiers are omitted.
| Timestamp | Observation |
|---|---|
| September 5, 06:14:30 | A download creation request returned 202. The artifact’s recorded creation time falls within the same second. |
| September 5, 06:15:04 | A download deletion returned 204, approximately 34 seconds later. A repeated deletion of the same download returned 404. |
| September 5, 06:15:12–06:15:24 | Another download creation and successful deletion occurred. Its relationship to the artifact could not be established from the retained audit fields. |
| September 5, 20:00:30 | Recovery reported the artifact’s output missing and requeued it. |
| September 6, 21:53:35 | Recovery requeued the same artifact for missing output. |
| September 7, 01:24:15 | Recovery requeued the same artifact for missing output. |
| September 7, 16:14:34 | Recovery requeued the same artifact for missing output. |
| September 8, 03:13:15 | Recovery requeued the same artifact for missing output. |
| September 8, 03:37:10 | Recovery requeued the same artifact for missing output. |
| September 8, 03:39:08 | The inspected application container started. |
| September 8, 03:42:59–03:43:10 | The artifact’s partial output grew between observations, confirming active encoding. No download referenced the artifact. |
The repeated operational log message was:
download artifact output missing, re-queuing
What was directly verified
- The artifact existed and was actively being encoded.
- No download row referenced its artifact ID.
- No download row remained for its media file ID.
- Its worker lease was being renewed.
- Its partial output file was growing.
- Six retained missing-output requeue messages identified the same artifact.
- The artifact output directory was not persistently mounted.
What remains uncertain
The original download row had been deleted, so its former artifact_id could not be inspected. The closely matching creation times strongly suggest the initial download and artifact were associated, but the retained audit record does not conclusively preserve that relationship.
The logs establish six requeue events, not six independently verified completed encodes.
Container recreation explains how the unmounted output can disappear while the database record survives. The cause of every historical output disappearance was not individually established.
Reproduction procedure
This procedure is derived from the observed incident and inspected implementation. It has not yet been executed as an isolated regression test.
- Start Silo with persistent PostgreSQL storage and a nonpersistent artifact output directory.
- Using a user permitted to download, request a download requiring remux or transcode preparation.
- Record the download-to-artifact association.
- Delete that download.
- Verify that no other download references the artifact.
- Observe whether queued or running preparation continues.
- If necessary, allow preparation to reach ready state.
- Recreate the application container while preserving PostgreSQL and discarding the temporary artifact output.
- Allow Prepare Download Artifacts to execute.
- Check for a missing-output requeue message and a new preparation process.
- Confirm that the artifact is being encoded despite having no download references.
- After completion, repeat container recreation to test repeated regeneration.
Also test deleting the last consumer while preparation is queued or running without recreating the container. That separates the consumer-lifecycle defect from the temporary-storage trigger.
Technical findings
Download deletion does not coordinate artifact preparation
In internal/downloads/service.go, Service.Delete:
- Deletes managed entries through
Repository.DeleteManaged. - Cancels or deletes ephemeral entries according to their state.
The inspected deletion paths do not coordinate with ArtifactManager to determine whether preparation has lost its final consumer.
Keeping shared artifacts independently is reasonable for reuse. The missing part is coordinating whether their preparation remains necessary.
Artifact claiming does not require a download reference
In internal/downloads/artifact_repo.go, ArtifactRepository.ClaimNext selects candidates using:
- Queued or running artifact state.
- Retry timing.
- Lease expiry.
The candidate query does not require a corresponding download reference.
An orphaned queued artifact therefore remains eligible for preparation. An orphaned running artifact can also be reclaimed when its lease expires.
Missing-output recovery requeues artifacts without checking demand
In internal/downloads/artifacts.go, ArtifactManager.recoverReadyArtifacts:
- Lists ready artifacts.
- Checks their local output paths.
- Requeues artifacts when the filesystem check fails.
The local recovery path does not check whether a download still needs the artifact before requeueing it.
This matches the retained missing-output messages and the actively running artifact with no consumers.
Recovery runs before orphan cleanup
ArtifactManager.RunOnce performs:
recoverQueueState
drain
recoverReadyArtifacts
drain
The enclosing task calls Cleanup afterward.
Consequently, a missing ready artifact can be requeued and processed before orphan cleanup is reached.
Orphan cleanup excludes queued and running work
ArtifactRepository.ListUnlinkedReadyBefore selects artifacts that:
- Have a ready status.
- Have no download references.
- Have a
last_used_atolder than the cutoff.
The configured unlinked-artifact retention is 30 days.
This leaves two gaps:
- Queued and running orphans do not qualify for the ready-only sweep.
- Recently used ready orphans can be regenerated even when no download needs them.
Successful regeneration refreshes retention
ArtifactRepository.MarkReady sets both:
completed_at = now(),
last_used_at = now()An unnecessary successful regeneration therefore refreshes the timestamp used to determine when an unreferenced artifact becomes eligible for cleanup.
Repeated regeneration can postpone age-based cleanup.
Requeue resets the attempt counter
ArtifactRepository.Requeue resets:
attempts = 0It also clears error, retry, completion, and lease state.
The observed attempt count therefore did not represent the artifact’s lifetime number of preparation attempts. The retry limit does not bound repeated successful preparation followed by output loss and requeue.
Temporary storage amplifies the defect
The durable database record survives container recreation, while an unmounted artifact directory does not.
A persistent artifact mount would prevent this particular source of output loss. It would not fix orphaned queued/running work or prevent regeneration after other forms of output loss.
Impact
- Unnecessary CPU/GPU use after the user has deleted the download.
- Repeated reads of source media and writes of generated output.
- Preparation slots occupied by work with no current consumer.
- Additional background load after container recreation.
- Confusing task activity when the user-visible download list is empty.
No data corruption or cross-user disclosure was established in this investigation.
Task observability
The task reports:
0%: Processing download artifact queue
100%: Download artifact queue drained
It does not report individual encode progress.
That is separate from the lifecycle defect, but makes the symptom harder to understand: the task can remain at 0% while an unnecessary encode is actively progressing.
Suggested fix scope
The implementation should distinguish retaining cached bytes from retaining demand to produce bytes.
Potential requirements:
- Define which download states count as consumers requiring preparation.
- Skip or retire orphaned queued work.
- Avoid requeueing missing output when no consumer requires it.
- Define cancellation behavior when the final consumer disappears during preparation.
- Preserve preparation required by other consumers.
- Coordinate consumer attachment, deletion, claiming, recovery, and cleanup.
- Preserve lease fencing and prevent obsolete workers from publishing output.
- Apply equivalent demand rules to local and remote artifacts.
- Handle cleanup of partial output according to the chosen lifecycle policy.
Concurrency constraint
A separate EXISTS check before encoding is not sufficient by itself.
The inspected creation path ensures the artifact before creating the linked download row. During that interval, a valid new artifact can temporarily have no download references.
A worker or cleanup pass must not interpret that temporary state as proof that the artifact is abandoned.
Similarly, deletion of the last observed consumer can race with another consumer attaching. Any fix must preserve shared-artifact behavior across devices, profiles, and accounts.
Regression tests
Consumer lifecycle
- Delete the sole consumer while preparation is queued.
- Delete the sole consumer while preparation is running.
- Delete one of multiple consumers and verify remaining downloads still complete.
- Replace a download’s quality/artifact while its previous preparation is running.
- Verify canceled or otherwise inactive download states follow the defined demand policy.
Recovery and storage
- Missing ready output with no consumers does not start another encode.
- Missing ready output with a valid consumer is regenerated.
- Container recreation with PostgreSQL retained does not regenerate orphaned artifacts.
- Repeated output loss does not cause an unbounded orphan regeneration cycle.
- Expired leases on orphaned work follow the same demand policy.
- Partial outputs are cleaned up safely.
- Existing unreferenced cached artifacts follow retention policy without being rebuilt solely to preserve the cache.
Concurrency
- Download creation races with worker claiming.
- Download creation races with orphan cleanup.
- Final-consumer deletion races with a new consumer attaching.
- Worker completion races with final-consumer deletion.
- A worker that loses its lease cannot publish stale output or alter the replacement worker’s result.
Artifact variants
- Ordinary artifact states.
- Tone-map artifact states.
- Audio-v2 artifact states.
- Local preparation.
- Remote preparation and cleanup.
- Readiness updates and notifications for legitimate remaining consumers.
Investigation status
This report is based on read-only inspection of application processes, output growth, PostgreSQL records, retained operational logs, request audit records, container mounts, and the source paths above.
No work was canceled or deleted during the investigation. No implementation or deployment changes were made. An isolated automated reproduction and regression fix remain outstanding.
Activity
[-]bug(downloads): orphaned download artifacts keep transcoding after their downloads are deleted[/-][+][bug] Orphaned download artifacts keep transcoding after their downloads are deleted[/+]scottrobertson commentedon Sep 23, 2026
I'm also seeing this, on
build-787(8e5ae2f, Docker, no persistent mount for/tmp/silo-download-artifacts).A couple of things that might be useful on top of the original report:
Cancelling the task doesn't stop it. I requested a movie download from the iOS app, then the next morning cancelled "Prepare Download Artifacts" from the admin UI and deleted the download 15 seconds later. The artifact's
last_used_atstill updated 13 minutes after that, andfile_sizewas filled in, so the encode kept running and finished anyway.From
activity_log(UTC):Same
audio_v2_runningstate as yours. When today's image update recreated the container, the artifact was re-queued and started a full transcode again, with nothing indownloadsoruser_downloads:time=2026-09-23T11:22:55.315+01:00 level=WARN msg="download artifact output missing, re-queuing" component=downloads artifact_id=144221027545645074 path=/tmp/silo-download-artifacts/1208_transcode_2fbedc28baa308ba.mp4status=audio_v2_running,audio_recipe_version=4,attempts=1/3, and it's the only row indownload_artifacts.My source files are on a network mount, so every image update re-reads the whole 13 GB source. That makes this a bit more painful than just the CPU time. I've left the row in place in case you want me to check anything else.
AI disclosure: I used Claude Code (claude-opus-5-5) to run the read-only DB and log queries and to help write this up. I checked it before posting.
fix(downloads): stop rebuilding missing artifacts no download uses (#…
Rhainland commentedon Nov 13, 2026
Reproduced on
origin/mainat 85d1c16: with two managed transcoded downloads, one encoding and one queued, deleting both left the running ffmpeg going to the end and then started the queued job. Both finished as ready files no download used.Cause: deleting a download never touched its preparation job, and the claim query picked up queued or lease-expired jobs whether or not any download still needed them. #1468 fixed missing-output recovery for ready files, but not work that was queued or running.
Fix in #4085: when the last waiting download of a job is deleted, revoked, or moved to another quality, the job is retired and its encode stops; a job another download still waits on keeps going. The preparation run also retires jobs nothing has needed for ten minutes, which covers other removal paths and orphaned rows left by earlier versions. Checked on a local build of the fix with the same steps: both jobs were retired during the delete requests, ffmpeg exited, and the partial file was removed. Deleting one of two downloads that share a job let the other finish, and asking for a deleted file again prepared it. DB-backed tests cover the delete, shared-job, late-link and stale-orphan cases, and a re-request while the stopped worker may still be running.
AI disclosure: reproduced and fixed by Claude Code (claude-opus-5-5) at the maintainer's direction.
fix(downloads): stop preparing a file once no download needs it (#4085)