Skip to content

ngx.location.capture 与 redis.set_keepalive合用导致worker进程退出 #108

Closed
@xukaifu

Description

@xukaifu

r1.lua 如下:

---- r1.lua
local redis = require "resty.redis"
local red = redis:new()
local ok, err = red:connect("192.168.191.69", 6379)
local ok, err = red:brpop("xxx", 10)
red:set_keepalive()
local http_ress = ngx.location.capture("/r2") -- 1
ngx.say("ok")

r2.lua 配置如下

---- r2.lua
local redis = require "resty.redis"
local red = redis:new()
local ok, err = red:connect("192.168.191.69", 6379) --2
local res = ngx.location.capture("/anyurl") --3

nginx.conf 配置如下

worker_processes  1;
error_log  logs/error.log  info;
pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {

    lua_package_path '/opt/openresty/nginx/lua2/include/?.lua;;';

    server {
        listen       8888;
        server_name  localhost;

        location /r1{
            default_type text/html;
            lua_code_cache off;
            lua_need_request_body on;
            content_by_lua_file lua2/r1.lua;
        }

        location /r2{
            default_type text/html;
            lua_code_cache off;
            lua_need_request_body on;
            content_by_lua_file lua2/r2.lua;
        }

        location /anyurl{
            internal;
            proxy_pass http://192.168.194.98/404.php;
        }

    }
}

先往redis里面弄点数据:

lpush xxx v1 
lpush xxx v1 
lpush xxx v1 
...

然后访问r1

curl localhost/r1

此时worker进程退出, debug日志中看到如下信息:
2012/04/27 18:25:24 [notice] 26423#0: signal 17 (SIGCHLD) received
2012/04/27 18:25:24 [alert] 26423#0: worker process 12262 exited on signal 11

redis 2.2.11 , 2.4.1 下均100%重现

只要注释掉代码1, 代码2, 代码3 中的任何一行, 都不会重现。。..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions