fix(nzb-dispatch): bound worker shutdown to one shared deadline (ported from fork) - #147
Merged
Merged
Conversation
(cherry picked from commit ec279d7)
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.
Summary
Ports
ec279d7from theMrVampy/rustnzbfork: a correctness fix forWorkerPoolshutdown.The bug (still present on main)
WorkerPool::shutdowngives each worker handle its own 10stokio::time::timeout:So worst-case shutdown time scales with worker count — N workers that all hang ⇒ up to N×10s before the pool gives up.
The fix
A single shared deadline via
timeout_at, after which any still-running handles are aborted, bounding total shutdown to ~10s regardless of worker count:Tests
Ships a
#[tokio::test(start_paused = true)]test,worker_shutdown_uses_one_shared_deadline, that spawns 3 never-completing workers and asserts the shutdown is still pending at 9s and completes once the single 10s deadline passes (proving it does not wait 3×10s).cargo test -p nzb-dispatch→ 42 passedcargo clippy -p nzb-dispatch --all-targets,cargo fmt --check→ cleanApplied cleanly onto main (pre-image matched byte-for-byte;
JoinHandlealready in scope).Original author: @MrVampy (commit preserved via
cherry-pick -x).🤖 Generated with Claude Code