Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

purgePeriodically function is left running for a while after pool.Release is called #212

Closed
ShivanshVij opened this issue Feb 8, 2022 · 0 comments
Assignees
Labels
bug Something isn't working pending development Requested PR owner to improve code and waiting for the result

Comments

@ShivanshVij
Copy link

Describe the bug
When the Pool.Release() function is called, it can leave the purgePeriodically function running until its heartbeat time.Ticker triggers, at which point the condition on whether the pool is closed is checked by the purgePeriodically for loop.

The issue is that one cannot assume the goroutines associated with an ant pool are completely cleaned up until the purgePeriodically function is completed - and as such, tools like goleak (https://github.com/uber-go/goleak) will report a leaked goroutine in tests.

To Reproduce
Steps to reproduce the behavior:

  1. Clone https://github.com/loopholelabs/frisbee
  2. Check out the rpc-async branch
  3. Run go test ./...
  4. See error

Expected behavior
The purgePeriodically goroutine is closed when the Release function returns.

Error messages/Trace logs

goleak: Errors on successful test run: found unexpected goroutines:
[Goroutine 4 in state chan receive, with github.com/panjf2000/ants/v2.(*Pool).purgePeriodically on top of the stack:
goroutine 4 [chan receive]:
github.com/panjf2000/ants/v2.(*Pool).purgePeriodically(0x14000140000)
        /Users/shivanshvij/go/pkg/mod/github.com/panjf2000/ants/v2@v2.4.7/pool.go:69 +0x80
created by github.com/panjf2000/ants/v2.NewPool
        /Users/shivanshvij/go/pkg/mod/github.com/panjf2000/ants/v2@v2.4.7/pool.go:137 +0x380
]
FAIL    github.com/loopholelabs/frisbee 10.624s

System info (please complete the following information):

  • OS: macOS
  • Go Version: 1.17.6
  • ants version: 2.4.7

Additional context
Add any other context about the problem here.

@ShivanshVij ShivanshVij added the bug Something isn't working label Feb 8, 2022
@panjf2000 panjf2000 added the pending development Requested PR owner to improve code and waiting for the result label Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending development Requested PR owner to improve code and waiting for the result
Projects
None yet
Development

No branches or pull requests

2 participants