You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/08/19 09:01:05 UTC
[GitHub] [apisix] nic-chen opened a new issue, #7746: bug: If the same configuration is used, different routes will share same limit for `limit-count`, even though they use different plugin_configs
nic-chen opened a new issue, #7746:
URL: https://github.com/apache/apisix/issues/7746
### Current Behavior
as the title
### Expected Behavior
not share the limit
### Error Logs
none
### Steps to Reproduce
1. Create two `plugin_config` with the same configuration
```
/apisix/plugin_configs/1
{"id":"1","plugins":{"limit-count":{"count":3,"key":"remote_addr","policy":"local","rejected_code":503,"time_window":60}}}
```
```
/apisix/plugin_configs/2
{"id":"2","plugins":{"limit-count":{"count":3,"key":"remote_addr","policy":"local","rejected_code":503,"time_window":60}}}
```
2. Create two routes, each using a different `plugin_config`
```
/apisix/routes/1
{"id":"1","plugin_config_id":"1","upstream_id":"1","uris":["/get"]}
```
```
/apisix/routes/2
{"id":"2","plugin_config_id":"2","upstream_id":"2","uris":["/anything"]}
```
4. Visit the route `/get` and you can see that there are 2 remaining left
```
curl 127.0.0.1:9080/get -i
...
X-RateLimit-Limit: 3
X-RateLimit-Remaining: 2
...
```
5. Visit the route `/anything`, this is only 1 remaining left (should have 2 left)
```
curl 127.0.0.1:9080/anything -i
...
X-RateLimit-Limit: 3
X-RateLimit-Remaining: 1
...
```
### Environment
- APISIX version (run `apisix version`): 2.13.2
- Operating system (run `uname -a`): Darwin
- OpenResty / Nginx version (run `openresty -V` or `nginx -V`): 1.19.3.1
- etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`): 3.4.20
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander closed issue #7746: bug: If the same configuration is used, different routes will share same limit for `limit-count`, even though they use different plugin_configs
Posted by GitBox <gi...@apache.org>.
spacewander closed issue #7746: bug: If the same configuration is used, different routes will share same limit for `limit-count`, even though they use different plugin_configs
URL: https://github.com/apache/apisix/issues/7746
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] kingluo commented on issue #7746: bug: If the same configuration is used, different routes will share same limit for `limit-count`, even though they use different plugin_configs
Posted by GitBox <gi...@apache.org>.
kingluo commented on issue #7746:
URL: https://github.com/apache/apisix/issues/7746#issuecomment-1220952161
@nic-chen @spacewander
The lastest version has also the same issue.
The reason is limit-count plugin uses the value of conf (json encoded) as the key of shdict, i.e. if the values of two conf are identical, then they share the same key, so the limit result affects each other.
https://github.dev/apache/apisix/blob/29f21a0eceb8eedc5d40ba68af154698f0eb70f4/apisix/plugins/limit-count.lua#L254
Maybe we should use the address of conf table as key, then as long as the conf is not substitute with new version, the key keeps individual and same:
```
key = ctx.conf_type .. tostring(conf) .. ':' .. key
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #7746: bug: If the same configuration is used, different routes will share same limit for `limit-count`, even though they use different plugin_configs
Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #7746:
URL: https://github.com/apache/apisix/issues/7746#issuecomment-1221541948
@kingluo
Thanks for pointing out this.
> Maybe we should use the address of conf table as key:
There is a feature that a change of the route which doesn't affect the limit-count configuration should not reset the counter, so we have to consider the value of conf table. Other plugins don't have this requirement.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org