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

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

Open
gcggcg opened this issue Jul 19, 2022 · 6 comments
Open

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

gcggcg opened this issue Jul 19, 2022 · 6 comments
Assignees
Labels
bug Something isn't working needs investigation This issue or proposal needs some investigations waiting for response waiting for the response from commenter

Comments

@gcggcg
Copy link

gcggcg commented Jul 19, 2022

System info (please complete the following information):

  • OS: Windows
  • Go Version: 1.17
  • ants version: v2.1.1

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

@gcggcg gcggcg added the bug Something isn't working label Jul 19, 2022
@panjf2000
Copy link
Owner

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

@panjf2000 panjf2000 added waiting for response waiting for the response from commenter needs investigation This issue or proposal needs some investigations labels Jul 19, 2022
@gcggcg
Copy link
Author

gcggcg commented Jul 26, 2022

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

@panjf2000
Copy link
Owner

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

@gcggcg
Copy link
Author

gcggcg commented Aug 2, 2022

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

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

@yundmb
Copy link

yundmb commented Oct 18, 2023

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

@xdsniper
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs investigation This issue or proposal needs some investigations waiting for response waiting for the response from commenter
Projects
None yet
Development

No branches or pull requests

4 participants