multiple stream group problem
somanybut opened this issue · 4 comments
How many checkers healthcheck does support maximum? Now, we have 20+ upstream groups, but we have found we can only have 8 checkers, when we write 9th checker, nginx can't start and report error: missing '}' character, but our config don't miss any '}'.
@somanybut Please provide a minimal and standalone example that can easily reproduce the problem on our side. Thanks!
we use Edition of openresty is 1.9.3.2, the configure file is:
lua_shared_dict healthcheck 10m;
lua_socket_log_errors on;
init_worker_by_lua_block {
init_worker_by_lua_block {
init_worker_by_lua_block {
init_worker_by_lua_block {
init_worker_by_lua_block {
init_worker_by_lua_block {
init_worker_by_lua_block {
init_worker_by_lua_block {
init_worker_by_lua_block {
local hc = require "resty.upstream.healthcheck"
local ok, err = hc.spawn_checker {
shm = "healthcheck",
upstream = "aaa",
type = "http",
http_req = "GET /service HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck",
upstream = "bbb",
type = "http",
http_req = "GET /service HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck",
upstream = "ccc",
type = "http",
http_req = "GET /service HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck",
upstream = "ddd",
type = "http",
http_req = "GET /service HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck",
upstream = "eee",
type = "http",
http_req = "GET /services HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck1",
upstream = "fff",
type = "http",
http_req = "GET /services HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck1",
upstream = "ggg",
type = "http",
http_req = "GET /services HTTP/1.0\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck1",
upstream = "hhh",
type = "http",
http_req = "GET /services HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck2",
upstream = "jjj",
type = "http",
http_req = "GET /services HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
}
}
}
}
}
}
}
}
}
of course, we try like this:
lua_shared_dict healthcheck 10m;
lua_socket_log_errors on;
init_worker_by_lua_block {
local hc = require "resty.upstream.healthcheck"
local ok, err = hc.spawn_checker {
shm = "healthcheck",
upstream = "aaa",
type = "http",
http_req = "GET /service HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck",
upstream = "bbb",
type = "http",
http_req = "GET /service HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck",
upstream = "ccc",
type = "http",
http_req = "GET /service HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck",
upstream = "ddd",
type = "http",
http_req = "GET /service HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck",
upstream = "eee",
type = "http",
http_req = "GET /services HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck1",
upstream = "fff",
type = "http",
http_req = "GET /services HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck1",
upstream = "ggg",
type = "http",
http_req = "GET /services HTTP/1.0\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck1",
upstream = "hhh",
type = "http",
http_req = "GET /services HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
ok, err = hc.spawn_checker {
shm = "healthcheck2",
upstream = "jjj",
type = "http",
http_req = "GET /services HTTP/1.0\r\nHost: tomcat\r\n\r\n",
interval = 2000,
timeout = 5000,
fall = 3,
rise = 2,
valid_statuses = {200, 302},
concurrency = 1,
}
if not ok then
ngx.log(ngx.ERR, "=======> failed to spawn health checker: ", err)
return
end
}
when we have 8 groups of upstream is ok, but upstream >10 aways fails:
[root@wms5hybsz1-I10 domains]# service nginx restart
停止 Nginx: [失败]
正在启动 Nginx:nginx: [emerg] Lua code block missing the "}" character in /export/servers/nginx/conf/domains/health.conf:112
[失败]
@somanybut @ajing2 Please try the latest OpenResty release. This looks like a known issue that has already been fixed in recent OpenResty versions. 1.9.3.2 is ancient :)
The latest OpenResty is ok! Thank you.