Grokzen / redis-py-cluster

Python cluster client for the official redis cluster. Redis 3.0+.
https://redis-py-cluster.readthedocs.io/
MIT License
1.1k stars 316 forks source link

version 2.1.3 raise rediscluster.exceptions.MovedError when connect redis cluster #500

Closed Vector-Cross closed 2 years ago

Vector-Cross commented 2 years ago

I use newest version redis-py-cluster==2.1.3 connect redis cluster with code

redis_store = RedisCluster(
    startup_nodes=startup_nodes,
    decode_responses=True,
    skip_full_coverage_check=True,
    readonly_mode=True,
    password=REDIS_PASSWORD
)
redis_store.get("foo")

raise rediscluster.exceptions.MovedError.

And I change version to redis-py-cluster==1.3.6 by using 'StrictRedisCluster' without this problem. Is there a bug for new version? How to fix it.

Grokzen commented 2 years ago

@Vector-Cross Is this exception raised back to you? Or are you just getting the log message written back to you? Most likley is that your redis-cluster is broken or not in a valid cluster state somehow. This usually happens when you use skip_full_coverage_check=True as that would validate if your cluster has everything covered properly. Check your cluster first.

Vector-Cross commented 2 years ago

@Vector-Cross Is this exception raised back to you? Or are you just getting the log message written back to you? Most likley is that your redis-cluster is broken or not in a valid cluster state somehow. This usually happens when you use skip_full_coverage_check=True as that would validate if your cluster has everything covered properly. Check your cluster first.

Is the exception raised back. I'm not sure my redis cluster is everthing ok. But I do use skip_full_coverage_check=False once and the exception raised in the first minute. Another thing is the exception not raised when I use the old version.

Grokzen commented 2 years ago

@Vector-Cross Can you paste the entire stack trace maybe? It is impossible to track down any error when i do not know where it comes from. If i look in the _execute_command method that you are using, there is no possible way that a MovedError is raised back to you as a user. It has to either be in the cluster discovery function or just before the try/except part. Older versions have nothing todo with anything. Also try to remove the readonly_mode=True, maybe your client is hitting a replica node that is not working as expected.

Vector-Cross commented 2 years ago

@Vector-Cross Can you paste the entire stack trace maybe? It is impossible to track down any error when i do not know where it comes from. If i look in the _execute_command method that you are using, there is no possible way that a MovedError is raised back to you as a user. It has to either be in the cluster discovery function or just before the try/except part. Older versions have nothing todo with anything. Also try to remove the readonly_mode=True, maybe your client is hitting a replica node that is not working as expected.

thanks for your reply. I'll see, maybe it is my enviroment problem or others. It's complicated due to using python-alpine as docker container. let me double check my code.