lua-resty-limit-traffic icon indicating copy to clipboard operation
lua-resty-limit-traffic copied to clipboard

[p0][conn-limit]blocked all traffic

Open yisitmxk opened this issue 1 year ago • 2 comments

https://github.com/openresty/lua-resty-limit-traffic/blob/master/lib/resty/limit/conn.md

Trigger condition: The backend API processing time exceeds the maximum timeout set in Nginx.

Problem triggered: During the log_by_lua phase, ctx.limit_conn is nil, resulting in the inability to invoke the lim:leaving function.

log_by_lua_block {
  local ctx = ngx.ctx
  local lim = ctx.limit_conn
  if lim then // lim is nil
      local latency = tonumber(ngx.var.request_time) - ctx.limit_conn_delay
      local key = ctx.limit_conn_key
      assert(key)
      local conn, err = lim:leaving(key, latency)
      if not conn then
          ngx.log(ngx.ERR,
                  "failed to record the connection leaving ",
                  "request: ", err)
          return
      end
  end
}

dict:incr(key, -1) not to execute, which accumulates and eventually leads to blocked all traffic. https://github.com/openresty/lua-resty-limit-traffic/blob/master/lib/resty/limit/conn.lua#LL58C4-L58C4 conn > max + self.burst Always true

yisitmxk avatar Jun 01 '23 08:06 yisitmxk