You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The goroutine will block at the select statement, I think the reason is that maybe there is no cancelFunc to awaken the ctx.Done(), which results in the select blocking. So the goroutine leak.
=== RUN TestAntsPoolWaitToGetWorker
ants_test.go:54: found unexpected goroutines:
[Goroutine 6 in state select, with github.com/panjf2000/ants/v2.(*Pool).purgeStaleWorkers on top of the stack:
github.com/panjf2000/ants/v2.(*Pool).purgeStaleWorkers(0xc00010abe0, {0x64ec08, 0xc000016320})
/home/song2048/桌面/goProject/src/awesomeProject/src/testdata/real-apps/src/github.com.new/ants/pool.go:84 +0xf8
created by github.com/panjf2000/ants/v2.(*Pool).goPurge in goroutine 1
/home/song2048/桌面/goProject/src/awesomeProject/src/testdata/real-apps/src/github.com.new/ants/pool.go:149 +0xd8
Goroutine 7 in state select, with github.com/panjf2000/ants/v2.(*Pool).ticktock on top of the stack:
github.com/panjf2000/ants/v2.(*Pool).ticktock(0xc00010abe0, {0x64ec08, 0xc000016370})
/home/song2048/桌面/goProject/src/awesomeProject/src/testdata/real-apps/src/github.com.new/ants/pool.go:127 +0x13f
created by github.com/panjf2000/ants/v2.(*Pool).goTicktock in goroutine 1
/home/song2048/桌面/goProject/src/awesomeProject/src/testdata/real-apps/src/github.com.new/ants/pool.go:156 +0x10b
]
ants_test.go:67: pool, running workers number:1000
ants_test.go:71: memory usage:4 MB
--- FAIL: TestAntsPoolWaitToGetWorker (10.56s)
FAIL
Code snippets (optional)
No response
How to Reproduce
You can use goleak to reproduce the bug easily like this
Does this issue reproduce with the latest release?
It can reproduce with the latest release
The text was updated successfully, but these errors were encountered:
It's supposed to be blocking when a pool starts, and then loop periodically to clean up idle workers. The context will be cancelled when you call Release().
It's supposed to be blocking when a pool starts, and then loop periodically to clean up idle workers. The context will be cancelled when you call Release().
Thank you for your reply. I read the relative codes carefully again, a potential goleak due to lacking of cancelFunc in Release() has been fixed in #287 successfully. I suppose it's right in the current version, and maybe it is a false positive reported by goleak.
Actions I've taken before I'm here
What happened?
Hello @panjf2000 , When I ran the test file,
ants/ants_test.go
Line 53 in 34ff2c2
ants/ants_test.go
Line 55 in 34ff2c2
The goroutine will block at the select statement, I think the reason is that maybe there is no cancelFunc to awaken the ctx.Done(), which results in the select blocking. So the goroutine leak.
ants/pool.go
Lines 84 to 88 in 34ff2c2
Major version of ants
v2
Specific version of ants
latest version
Operating system
Linux
OS version
Ubuntu 22.04.3 LTS
Go version
Go 1.21.7
Relevant log output
Code snippets (optional)
No response
How to Reproduce
You can use goleak to reproduce the bug easily like this
Does this issue reproduce with the latest release?
It can reproduce with the latest release
The text was updated successfully, but these errors were encountered: