Skip to content
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

request help: limit-count-redis time_window 1 may cause reject to some request under count #5588

Closed
jinyuxiaoqiang opened this issue Nov 23, 2021 · 1 comment

Comments

@jinyuxiaoqiang
Copy link

Issue description

While using plugin 'limit-count',i encountered a problem:
situation:count:3000,time_window:1,rejected_code:503,policy:"redis",key:$remote_addr。
reproduce: when requsting a route with above limit-count config a bit frequent about 500qps,apisix will return rejected_code.
Adding log to limit-count.lua _M.access() and limit-count-redis.lua. I find an issue:
local ret, err = red:ttl(key) => ret = 0
local b_key, err = red:get(key) =>b_key = null
remaining, err = red:incrby(key, -1) => remaining = -1
local a_key, err = red:get(key) => a_key = -1
then leads to return nil, "rejected".
so ret = 0 means key will expire soon,when executing the code after get ttl, the key is very likely deleted.
please help to confirm the issue,thanks

Environment

  • apisix version (cmd: apisix version):2.2
  • OS (cmd: uname -a): Linux 820301ecfc7b 5.4.0-48-generic doc: add doc for limit count.  #52-Ubuntu SMP Thu Sep 10 10:58:49 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • OpenResty / Nginx version (cmd: nginx -V or openresty -V): nginx version: openresty/1.19.3.1
  • etcd version, if have (cmd: run curl http://127.0.0.1:9090/v1/server_info to get the info from server-info API): etcdctl version: 3.4.13. API version: 3.4
  • apisix-dashboard version, if have:2.3.0
  • the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner):
  • luarocks version, if the issue is about installation (cmd: luarocks --version):
    3.5.0
@jinyuxiaoqiang jinyuxiaoqiang changed the title request help: request help: limit-count-redis time_window 1 may cause reject to some request under count Nov 23, 2021
@tzssangglass
Copy link
Member

maybe solved by:#3991

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants