change(limit-count): ensure redis cluster name is set correctly#3910
Conversation
…ess test prompting ' ttl: ERR invalid passwor'
|
Could you please add some test cases to cover the scene that you said? |
| local function new_redis_cluster(conf) | ||
| local config = { | ||
| name = "apisix-redis-cluster", | ||
| name = "apisix-redis-cluster-" .. conf.name, |
There was a problem hiding this comment.
I am confused by the solution. What is the relation between the password and name?
There was a problem hiding this comment.
one name Mapping one routes,if all redis_cluster config the same name. When concurrent lrucache can not find the correct redis_cluster in pool.
This is my personal opinion ,maybe it is wrong.😄
There was a problem hiding this comment.
I read through the resty.rediscluster. Look like this library uses a module-level slot_cache, and the key is the config.name.
So it is no doubted that different configurations with the same name will collide.
What about using "apisix-redis-cluster-" .. tostring(conf) directly?
Better to add a comment about this change as future maintainers may not read through the library.
Different routes using the same cluster will still need to share the slot_cache. Would it be better to use crc32(nodes) to generate the suffix?
Sorry for my fickle mind. It seems the library doesn't provide a way to clean up stale cached slots. So using auto-generated name is unsafe. My latest idea is to require user to specify the name of redis cluster. It is a break change but it is reasonable to introduce break change to fix bug.
ok,I can paste some of my test configuration and test results then I stress test two routes at the same time,i use the go-stress-testing test the url like this: you can see my error.log it output errror like this: |
| local function new_redis_cluster(conf) | ||
| local config = { | ||
| name = "apisix-redis-cluster", | ||
| name = "apisix-redis-cluster-" .. conf.name, |
There was a problem hiding this comment.
I read through the resty.rediscluster. Look like this library uses a module-level slot_cache, and the key is the config.name.
So it is no doubted that different configurations with the same name will collide.
What about using "apisix-redis-cluster-" .. tostring(conf) directly?
Better to add a comment about this change as future maintainers may not read through the library.
Different routes using the same cluster will still need to share the slot_cache. Would it be better to use crc32(nodes) to generate the suffix?
Sorry for my fickle mind. It seems the library doesn't provide a way to clean up stale cached slots. So using auto-generated name is unsafe. My latest idea is to require user to specify the name of redis cluster. It is a break change but it is reasonable to introduce break change to fix bug.
Co-authored-by: Yuelin Zheng <[email protected]>
Co-authored-by: Yuelin Zheng <[email protected]>
|
Don't forget to update the example: https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/limit-count.md |
…ess test prompting ' ttl: ERR invalid passwor'
What this PR does / why we need it:
during the stress test, I found that if the limit-count plugin configures multiple different redis-cluster data sources, the following error will appear failed to get redis
plugin-limit-countxx.xx.xx.xxroute122ttl: ERR invalid password so I Fixed itPre-submission checklist: