hi, 现在我这里通过ngx.thread.spawn中启动一个线程,这个线程中会通过lua-resty-mysql从mysql获取数据,但是在初始化mysql连接的时候mysql:new()抛出这样的错误:failed to issue subrequest: -1。这个是什么原因导致的?目前我这里的逻辑流程是这样的:1.通过ngx.thread.spawn启动N个线程,这些线程会去通过lua-resty-mysql连接数据库执行数据统计操作2.为了防止一次性并发执行的线程太多,通过ngx.thread.wait等待前面N个线程的返回,全部返回后又通过ngx.thread.spawn新生成新的N个线程循环执行 --
漏了一个,总共有2条错误提示:1.subrequests cycle while processing "/mysql" while sending to client
2.failed to issue subrequest: -1在 2015-11-10 20:00:24,"熊云昆" <xiong...@163.com> 写道: hi, 现在我这里通过ngx.thread.spawn中启动一个线程,这个线程中会通过lua-resty-mysql从mysql获取数据,但是在初始化mysql连接的时候mysql:new()抛出这样的错误:failed to issue subrequest: -1。这个是什么原因导致的?目前我这里的逻辑流程是这样的:1.通过ngx.thread.spawn启动N个线程,这些线程会去通过lua-resty-mysql连接数据库执行数据统计操作2.为了防止一次性并发执行的线程太多,通过ngx.thread.wait等待前面N个线程的返回,全部返回后又通过ngx.thread.spawn新生成新的N个线程循环执行 -- --
In older versions of Nginx, the limit was 50 concurrent subrequests and in more recent versions, Nginx 1.1.x onwards, this was increased to 200 concurrent subrequests. When this limit is exceeded, the following error message is added to the error.log file:
50
1.1.x
200
error.log
[error] 13983#0: *1 subrequests cycle while processing "/uri"
这里我的线程数应该是超过了200个了,所以抛出这个错误,引起了第二个错误failed to issue subrequest: -1
现在我改成了将线程放入数组,循环数组依次调用ngx.thread.wait方法,这样就能保证上一次执行的N个线程确保都已经执行完毕
Hello,你确认是 mysql.new 抛出来的错误?在 2015年11月10日 下午8:11,熊云昆 <xiong...@163.com>写道:漏了一个,总共有2条错误提示:1.subrequests cycle while processing "/mysql" while sending to client从这里看,你是发起子请求到 /mysql 呢? 2.failed to issue subrequest: -1在 2015-11-10 20:00:24,"熊云昆" <xiong...@163.com> 写道: hi, 现在我这里通过ngx.thread.spawn中启动一个线程,这个线程中会通过lua-resty-mysql从mysql获取数据,但是在初始化mysql连接的时候mysql:new()抛出这样的错误:failed to issue subrequest: -1。这个是什么原因导致的?目前我这里的逻辑流程是这样的:1.通过ngx.thread.spawn启动N个线程,这些线程会去通过lua-resty-mysql连接数据库执行数据统计操作2.为了防止一次性并发执行的线程太多,通过ngx.thread.wait等待前面N个线程的返回,全部返回后又通过ngx.thread.spawn新生成新的N个线程循环执行 -- -- --
sorry,我的程序bug,ngx.thread.wait(thread1, thread2, ...)这个是第一个线程返回了的话这个函数就会直接返回,可能thread2等其他线程还在执行,这样就导致了上一次有线程还在执行我又去新生成了N个线程,看文档说:In older versions of Nginx, the limit was 50 concurrent subrequests and in more recent versions, Nginx 1.1.x onwards, this was increased to 200 concurrent subrequests. When this limit is exceeded, the following error message is added to the error.log file: [error] 13983#0: *1 subrequests cycle while processing "/uri"这里我的线程数应该是超过了200个了,所以抛出这个错误,引起了第二个错误failed to issue subrequest: -1现在我改成了将线程放入数组,循环数组依次调用ngx.thread.wait方法,这样就能保证上一次执行的N个线程确保都已经执行完毕 在 2015-11-10 20:40:38,"DeJiang Zhu" <douj...@gmail.com> 写道: Hello,你确认是 mysql.new 抛出来的错误?在 2015年11月10日 下午8:11,熊云昆 <xiong...@163.com>写道:漏了一个,总共有2条错误提示:1.subrequests cycle while processing "/mysql" while sending to client从这里看,你是发起子请求到 /mysql 呢? 2.failed to issue subrequest: -1在 2015-11-10 20:00:24,"熊云昆" <xiong...@163.com> 写道: hi, 现在我这里通过ngx.thread.spawn中启动一个线程,这个线程中会通过lua-resty-mysql从mysql获取数据,但是在初始化mysql连接的时候mysql:new()抛出这样的错误:failed to issue subrequest: -1。这个是什么原因导致的?目前我这里的逻辑流程是这样的:1.通过ngx.thread.spawn启动N个线程,这些线程会去通过lua-resty-mysql连接数据库执行数据统计操作2.为了防止一次性并发执行的线程太多,通过ngx.thread.wait等待前面N个线程的返回,全部返回后又通过ngx.thread.spawn新生成新的N个线程循环执行 -- -- -- --
Hello,以我目前的理解,线程数应该没有 200 的限制我怀疑,你是不是在 thread里 发起子请求了呢? PS: 确实 thread 太多也不太好,你这样一批批来是应该的在 2015年11月10日 下午9:20,熊云昆 <xiong...@163.com>写道:sorry,我的程序bug,ngx.thread.wait(thread1, thread2, ...)这个是第一个线程返回了的话这个函数就会直接返回,可能thread2等其他线程还在执行,这样就导致了上一次有线程还在执行我又去新生成了N个线程,看文档说:In older versions of Nginx, the limit was 50 concurrent subrequests and in more recent versions, Nginx 1.1.x onwards, this was increased to 200 concurrent subrequests. When this limit is exceeded, the following error message is added to the error.log file: [error] 13983#0: *1 subrequests cycle while processing "/uri"这里我的线程数应该是超过了200个了,所以抛出这个错误,引起了第二个错误failed to issue subrequest: -1现在我改成了将线程放入数组,循环数组依次调用ngx.thread.wait方法,这样就能保证上一次执行的N个线程确保都已经执行完毕 在 2015-11-10 20:40:38,"DeJiang Zhu" <douj...@gmail.com> 写道: Hello,你确认是 mysql.new 抛出来的错误?在 2015年11月10日 下午8:11,熊云昆 <xiong...@163.com>写道:漏了一个,总共有2条错误提示:1.subrequests cycle while processing "/mysql" while sending to client从这里看,你是发起子请求到 /mysql 呢? 2.failed to issue subrequest: -1在 2015-11-10 20:00:24,"熊云昆" <xiong...@163.com> 写道: hi, 现在我这里通过ngx.thread.spawn中启动一个线程,这个线程中会通过lua-resty-mysql从mysql获取数据,但是在初始化mysql连接的时候mysql:new()抛出这样的错误:failed to issue subrequest: -1。这个是什么原因导致的?目前我这里的逻辑流程是这样的:1.通过ngx.thread.spawn启动N个线程,这些线程会去通过lua-resty-mysql连接数据库执行数据统计操作2.为了防止一次性并发执行的线程太多,通过ngx.thread.wait等待前面N个线程的返回,全部返回后又通过ngx.thread.spawn新生成新的N个线程循环执行 -- -- -- -- --
Hello! 2015-11-10 20:00 GMT+08:00 熊云昆: > 现在我这里通过ngx.thread.spawn中启动一个线程,这个线程中会通过lua-resty-mysql从mysql获取数据,但是在初始化mysql连接的时候mysql:new()抛出这样的错误:failed > to issue subrequest: -1。这个是什么原因导致的? 只有 ngx.location.capture 和 ngx.location.capture_multi 调用才有可能返回这个错误。lua-resty-mysql 和 ngx.thread API 不可能返回此错误。请仔细检查你的代码。 Regards, -agentzh