panjf2000 / ants

🐜🐜🐜 ants is the most powerful and reliable pooling solution for Go.
https://ants.andypan.me/
MIT License
12.83k stars 1.36k forks source link

设置最大阻塞后异常,而且不会恢复原来的运行 #239

Closed gcggcg closed 1 week ago

gcggcg commented 2 years ago

System info (please complete the following information):

问题描述: 当前项目中采用的是ants.NewPoolWithFunc()方式进行协程处理并发任务,同时设置了最大阻塞ants.WithMaxBlockingTasks(100). 项目开始运行没有问题,但是当任务执行达到最大阻塞值的时候,项目就停止运行了,直接报错: too many goroutines blocked on submit or Nonblocking is set 这种错提示超过了阻塞大小,任务注入失败,但是问题出现在任务持续报错(任务里面不涉及阻塞代码逻辑),也就是我的之前的任务执行完成后也没有进行释放,验证方式是: 我才用定时器去触发任务9点启动,但是15点观察10点后就没有了任务数据,原因排查就是持续抛错,没有释放。这种该如何处理,有没有机制可以抛出这个异常让阻塞队列数据清空,这样我的新任务就可以成功了。或者有什么方式可以解决这个问题。

panjf2000 commented 2 years ago

请升级到最新的 v2.5.0,看看是否解决,我记得后来的新版本应该修复了这种问题。

gcggcg commented 2 years ago

请问如果当前项目没有升级到2.50版本,设置最大的阻塞为0,是不是表示阻塞队列无限大,也不会出现上面的问题。

panjf2000 commented 2 years ago

你可以用 NewPool(-1),设置 pool 的容量不限制,试试能不能解决。

gcggcg commented 2 years ago

请升级到最新的 v2.5.0,看看是否解决,我记得后来的新版本应该修复了这种问题。

首先当前使用的包就是v2.5.0,出现的这个问题,然后我当前采用的函数是NewPoolWithFunc()方式,进行设置协程执行的函数,没有采用NewPool(-1)。你的文档上面写的NewPoolWithFunc()方式,默认阻塞为0,就是不限制。

yundmb commented 12 months ago

我也碰到这样的问题,任务明明已经结束了,通过日志查看,但是running一直不减少

xdsniper commented 12 months ago

请问如果当前项目没有升级到2.50版本,设置最大的阻塞为0,是不是表示阻塞队列无限大,也不会出现上面的问题。

我也有这个疑问,设置阻塞并且最大阻塞值为0的情况下,是不是代表submit之后一定可以获取到有效的work?今天发现线上因为没有处理提交异常导致协程溢出了,明显加个debug日志看下什么情况。

github-actions[bot] commented 2 weeks ago

This issue is marked as stale because it has been open for 30 days with no activity.

You should take one of the following actions:

This issue will be automatically closed in 7 days if no further activity occurs.

github-actions[bot] commented 1 week ago

This issue was closed because it has been inactive for 7 days since being marked as stale.

If you believe this is a false alarm, please leave a comment for it or open a new issue, you can also reopen this issue directly if you have permission.