Hello!
On Tue, Oct 23, 2012 at 9:09 PM, ganggewudi wrote:
> openresty 1.2.1.14
> OS是Linux version 2.6.32-279.5.2.el6.x86_64
> (mockbuild@c6b10.bsys.dev.centos.org) (gcc version 4.4.6 20120305 (Red Hat
> 4.4.6-4) (GCC) ) #1 SMP Fri Aug 24 01:07:11 UTC 2012
你可以考虑升级到最新的 openresty 稳定版 1.2.3.8 或者开发版 1.2.4.3 :)
http://openresty.org/#Download
然后使用 Nginx 热替换功能进行动态替换:
http://wiki.nginx.org/CommandLine#Upgrading_To_a_New_Binary_On_The_Fly
注意,当你升级 Nginx 本身时,-sreload 和 HUP 信号重新加载配置是无效的。
> 日志:
> 2012/10/23 11:57:00 [error] 13828#0: *53098 [lua] db_func.lua:24:
> dodbquery(): Access denied for user 'xxxx'@'xx.xx.xx.xx' to database
> 'p2preport', client: 222.73.27.71, server: localhost, request: "GET
> http://114.80.122.98:8080/insert?table=online_num(ip,serType,ver,num,operTime)&val=values('222.73.27.71',0,1610001,600,'2012-10-23%2011:57:00')
> HTTP/1.1", host: "222.73.27.71"
> 2012/10/23 11:57:00 [error] 13828#0: *53098 [lua] db_func.lua:24:
> dodbquery(): Access denied for user 'xxxx'@' xx.xx.xx.xx ' to database
> 'p2preport', client: 222.73.27.71, server: localhost, request: "GET http://
> xx.xx.xx.xx
> :xxxx/insert?table=online_num(ip,serType,ver,num,operTime)&val=values('222.73.27.71',0,1610118,5222,'2012-10-23%2011:57:00')
> HTTP/1.1", host: "222.73.27.71"
> 2012/10/23 13:04:08 [error] 13828#0: *53383 access forbidden by rule,
> client: 180.168.168.82, server: localhost, request: "HEAD / HTTP/1.0"
> 2012/10/23 13:18:48 [error] 13828#0: *53444 access forbidden by rule,
> client: 60.173.11.149, server: localhost, request: "GET http://im.qq.com/
> HTTP/1.1", host: "im.qq.com"
> 2012/10/23 16:11:01 [notice] 14275#0: signal process started
很奇怪的是,你提供的日志中只有这一行 notice 消息。在 HUP 重启时,应该会看到下面这些消息(按出现顺序):
2012/10/24 14:45:20 [notice] 3574#0: signal process started
2012/10/24 14:45:20 [notice] 3428#0: signal 1 (SIGHUP) received, reconfiguring
2012/10/24 14:45:20 [notice] 3428#0: reconfiguring
2012/10/24 14:45:20 [notice] 3428#0: using the "epoll" event method
2012/10/24 14:45:20 [notice] 3428#0: start worker processes
2012/10/24 14:45:20 [notice] 3428#0: start worker process 3587
2012/10/24 14:45:20 [notice] 3429#0: gracefully shutting down
2012/10/24 14:45:20 [notice] 3429#0: exiting
2012/10/24 14:45:20 [notice] 3429#0: exit
2012/10/24 14:45:20 [notice] 3428#0: signal 17 (SIGCHLD) received
2012/10/24 14:45:20 [notice] 3428#0: worker process 3429 exited with code 0
2012/10/24 14:45:20 [notice] 3428#0: signal 29 (SIGIO) received
为何你提供的日志中只出现了第一行消息?是因为你提供的日志还不够完整么?
> 2012/10/23 16:11:02 [error] 14276#0: *54929 lua tcp socket read timed out,
> client: 222.73.27.71, server: localhost, request: "GET http:// xx.xx.xx.xx
> :xxxx
> /insert?table=online_num(ip,serType,ver,num,operTime)&val=values('222.73.27.71',0,1610107,4,'2012-10-23%2016:11:00')
> HTTP/1.1", host: "222.73.27.71"
> 2012/10/23 16:11:02 [error] 14276#0: *54929 [lua] db_insert.lua:19:
> dodbquery(): failed to connect mysql, client: 222.73.27.71, server:
> localhost, request: "GET http:// xx.xx.xx.xx :xxxx
> /insert?table=online_num(ip,serType,ver,num,operTime)&val=values('222.73.27.71',0,1610107,4,'2012-10-23%2016:11:00')
> HTTP/1.1", host: "222.73.27.71"
你能在 Lua 代码中把方法调用返回的 err 出错消息也打印出来么?同时你这条消息是在哪一步操作失败时打印的?是 connect 还是 query 还是其他?
另外,你是否启用了 mysql 连接池?
我使用简单的 lua-resty-mysql 接口查询 select sleep(0.1) 然后施加 ab 10 并发压力再反复使用 HUP
重启,无法复现你的问题(我得不到任何错误)。
你可以考虑尝试使用前面提到的热替换技术替代 -sreload,看看问题是否依旧。
另外也可以尝试把 lua-resty-mysql 对象的超时设置适当调大(我从日志上估计你应当设置的是 1 秒),看看是否问题会消失。
Best regards,
-agentzh