-
Notifications
You must be signed in to change notification settings - Fork 51
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
too many pending timers #40
Comments
typically when calling those delay-timers, from a single thread, the timers do not get executed because they need the thread to yield first. In that case, each time after adding 100 servers, do a Are you creating the full 2000 entries from a single thread without yielding? Your timer limit is rather low with 256. |
implementing a different async method could prevent it from happening, something like; local run_async do
local list = {}
function handler(premature)
local exec_list = list
list = {}
for _, tmr in ipairs(exec_list) do
local ok, err = pcall(tmr[1], premature, unpack(tmr, 2, tmr.n))
if not ok then
ngx.log(ngx.ERR, "timer failure: ", err)
end
end
end
function run_async(...)
local l = #list
list[#l + 1] = { n = select("#", ...), ... }
if l == 0 then
local ok, err = ngx.timer.at(0, handler)
if not ok then
return ok, err
end
end
return true
end
end (top of head, untested) |
Actually the original implementation uses sleep but sleep api is not available in the init phase, this change is introduced in 14b894a#diff-224173b5a7345f5a7a2eb86000f00616 Thanks for your suggestion to go async, I'll try in my application. Maybe it's better to change this library to use async? |
@dotSlashLu So you are hitting the "not enough timers" in the init phase? (and for the record; the idea would be to implement that async code in the library 😄 , not in user code) @hishamhm @locao the above code would probably resolve the error, but I'm not to happy with overall overhead. Any other ideas for reducing this timer issue? |
the idea would be wherever the code calls |
Hi, I'm using the master branch and encountered this error:
Is there a limit for how many targets I can add? Is it possible to add more than 2000 upstream servers?
seems to be related to
locking_target_list
whenadd_target
lua-resty-healthcheck/lib/resty/healthcheck.lua
Line 232 in 68f0cc6
The text was updated successfully, but these errors were encountered: