Repository navigation
fix(pool): skip queued Go tasks when the pool context is canceled - #150
Merged
Merged
Conversation
Go submits the raw function, so unlike Submit, SubmitErr, TrySubmit and TrySubmitErr it never checks the pool context before running the task. Tasks still queued when the context is canceled ran anyway and were counted as successful instead of canceled. Wrap the task the same way the other submit methods do. The test cancels the context while a queued Go task waits behind a running one.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #150 +/- ##
=======================================
Coverage 95.81% 95.81%
=======================================
Files 11 11
Lines 622 622
=======================================
Hits 596 596
Misses 23 23
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Gosubmits the task unwrapped, so unlike theSubmitandTrySubmitvariants it never checks the pool context. AGotask still queued when the context is canceled runs anyway and counts as successful, not canceled. The README says drained tasks "are not executed".a2e34e8 (v2.7.0) moved the context check from
readTasktowrapTask. Before it, a queuedGotask did not run after cancellation.Gonever usedwrapTask(pool.go#L333-L335), so it lost the check.Wrap the task with
wrapTaskand the pool context, aswrapAndSubmitdoes. The callback is a no-op becauseGohas no future. The test mirrorsTestPoolStopAndWaitShouldNotDeadlockWhenContextCanceledWithQueuedTasks.Validation (Go 1.27.0):
52d2178in 3 of 3 runs with-raceand passes with the fix in 50 of 50.go test -race ./...,go vet ./...andgit diff --checkare clean.Gomakes one more allocation per call (2 instead of 1);Submitmakes 7.