fix(syntaxis): correct download dispatch (slot leaks, retry wakeup, protocol guard) - #489
Merged
Merged
Conversation
…rotocol guard) - #393: extract the duplicated dispatch/spawn logic into one helper; a start_download failure now releases the slot, removes the active entry, marks the row failed, and pulls a replacement from the queue. - #394: the retry re-enqueue now wakes the dispatcher (the spawned retry task calls the shared dispatch helper after backoff). - #424: dispatch matches on protocol and fails a Usenet/NZB item loudly (marked-failed, slot rolled back) instead of silently mis-routing it to the BitTorrent engine. Full Usenet support is a separate feature. - #425: collapse the priority-4 has_slot/acquire/insert into one critical section; losers demote to priority 3. - #426: on broadcast Lagged (and a 60s periodic pass) reconcile active downloads against the engine so dropped DownloadCompleted events no longer permanently leak slots. - #427: retry_count is carried on QueueItem and restored from the DB so the retry budget survives process restarts. - #428: regression test that a retried download is re-dispatched after backoff. Closes #393 Closes #394 Closes #424 Closes #425 Closes #426 Closes #427 Closes #428 Gate-Passed: kanon 0.1.5 +stages:fmt,check,clippy,nextest,lint sha:6f9621834cb6aeceb9cda349b84b610ae7e826d8
forkwright
added a commit
that referenced
this pull request
Jul 2, 2026
…it (#493) #491 (ergasia) changed DownloadEngine::extract to async (impl Future) so extraction runs off the executor; #489 (syntaxis) merged a test MockEngine whose extract was still sync. The two PRs were each internally consistent but ergasia was tested pre-syntaxis, so the stale mock only broke the workspace build once both landed. Make the mock extract async. Gate-Passed: kanon 0.1.5 +stages:fmt,check,clippy,nextest,lint sha:77b78bec2dcb0e1e949146db9e7a348590cc816e Co-authored-by: forkwright <noreply@forkwright.dev>
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 #393, #394, #424, #425, #426, #427, #428.
Changes
start_downloadfailure permanently leaks a concurrency slot, active entry, and DB row #393 — slot/row leak. Astart_downloadfailure leaked the concurrency slot, active entry, and left the row non-terminal. The dispatch logic is now one shared helper that releases the slot, removes the active entry, marks the row failed, and pulls a replacement.Torrentprotocol, breaking all NZB/Usenet downloads #424 — protocol mis-route. Dispatch hardcodedTorrent, silently mis-routing NZB/Usenet to the BitTorrent engine. It now matches on protocol and fails a Usenet item loudly (marked-failed, slot rolled back) instead. Full Usenet support is a separate feature.has_slotcheck andacquirein priority-4enqueueallows active_total to exceed max_concurrent #425 — TOCTOU. The priority-4has_slot/acquire/insertcollapse into one critical section; losers demote to priority 3.Lagged(and a 60s periodic pass) active downloads are reconciled against the engine, so droppedDownloadCompletedevents no longer permanently leak slots.retry_countis carried onQueueItemand restored from the DB.Verification
kanon gate --fullgreen (fmt, check, advisory-parity, cargo-deny, clippy workspace, nextest, kanon lint). 179 tests across syntaxis + archon.