hammer-backend-redis icon indicating copy to clipboard operation
hammer-backend-redis copied to clipboard

Problem connecting with Redis Cluster

Open carlogilmar opened this issue 2 years ago • 6 comments

Describe the bug

Recently we're trying to connect a redis cluster for use with Hammer, but we got an error that comes from Redix:

image

Following this: https://github.com/whatyouhide/redix/issues/240, looks like this error comes from Redix that doesn't have support for the redis cluster moved errors.

Not sure what is the best way to handle this, I think we can handle the errors coming from Redix and create a new connection for the correct node and using redix we can send and get the data.

carlogilmar avatar Jan 30 '23 17:01 carlogilmar

oh interesting. I did not know also that was a thing .Thanks for linking the original issue. So what fixes it? I am unclear what moves does? seems that we would need to restart the pool to fix it?

epinault avatar Jan 30 '23 17:01 epinault

I'm not sure how a redis cluster works, but looks like when you add a new record, it will stored in a certain connection, and if you need a record stored there, you need to execute the command in that particular connection:

image

But, nevermind, I'm still looking into this 👀

carlogilmar avatar Jan 30 '23 18:01 carlogilmar

But if I added the records using the redis-cli, looks like you can add and get the data from any part of the cluster 🤔 image

carlogilmar avatar Jan 30 '23 19:01 carlogilmar

Happy to help to add changes for this @epinault 😁

I added some changes here: https://github.com/ExHammer/hammer-backend-redis/pull/40

carlogilmar avatar Jan 31 '23 23:01 carlogilmar

left some question in the MR. Happy to look at it more next week.

epinault avatar Feb 04 '23 01:02 epinault

@epinault I think it is easier if eredis_cluster can be used for redis_cluster case

and for normal redis, the eredis package

Basically, to change the Redix dependency to eredis + eredis_cluster in favor of more features

sonic182 avatar Sep 22 '23 10:09 sonic182