-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
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? |
@@ -32,7 +32,7 @@ local mt = { | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused by the solution. What is the relation between the password and name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
@@ -32,7 +32,7 @@ local mt = { | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.xxroute122
ttl: ERR invalid password so I Fixed itPre-submission checklist: