Skip to content
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

redis cluster client throws error on calling module_list() #2888

Closed
sseide opened this issue Aug 11, 2023 · 0 comments · Fixed by #2951
Closed

redis cluster client throws error on calling module_list() #2888

sseide opened this issue Aug 11, 2023 · 0 comments · Fixed by #2951
Labels
bug Bug

Comments

@sseide
Copy link

sseide commented Aug 11, 2023

Version: What redis-py and what redis version is the issue happening on?

redis_py 4.6.0
Server 6.0.16 (Debian 11 package) and newer (like 6.2 or 7.0)- Server must be run in Cluster mode

Platform: What platform / version? (For example Python 3.5.1 on Windows 7 / Ubuntu 15.10 / Azure)
python 3.11 on Debian 12

Description: Description of your issue, stack traces from errors and code that reproduces the issue

Creating an "normal" Redis client i am able to call the method module_list() on the client and get an list response (either empty or filled, depending on the server and modules installed there. Its working fine.

Same is true for an Client created from a Redis Sentinel based connection. Calling module_list() gives a list response as expected.

Now - whenever i create a Redis Cluster client the method cannot be called anymore, the client throws an exception instead of returning the list with all modules installed.

Example oth the error:

from redis.cluster import RedisCluster as Redis
client = Redis.from_url(redis_url)

client.module_list()
# ==> {AttributeError}'RedisCluster' object has no attribute 'module_list'

client.execute_command('module', 'list')
# ==> {RedisClusterException}No way to dispatch this command to Redis Cluster. Missing key.
#        You can execute the command by specifying target nodes.
#        Command: ('module', 'list')

Working code - tested against the same server version. With the regular client i can connect to one cluster node directly also and call module_list() there too without problem (but not the get() and similar methods - there i get the "MOVED" answers as expected for cluster nodes):

import redis
client = redis.from_url(redis_url)
client.module_list()
# ==> list with modules
import redis
sentinel = redis.sentinel.Sentinel(sentinel_list)
client = sentinel.master_for('mymaster')
client.module_list()
# ==> list with modules

As the Cluster Redis client is expected to be a drop in replacement for most client actions the "module" methods should all be available there too.

Thanks in advance for looking into it

baskaryan added a commit to langchain-ai/langchain that referenced this issue Aug 11, 2023
This change updates the central utility class to recognize a Redis
cluster server after connection and returns an new cluster aware Redis
client. The "normal" Redis client would not be able to talk to a cluster
node because keys might be stored on other shards of the Redis cluster
and therefor not readable or writable.

With this patch clients do not need to know what Redis server it is,
they just connect though the same API calls for standalone and cluster
server.

There are no dependencies added due to this MR.

Remark - with current redis-py client library (4.6.0) a cluster cannot
be used as VectorStore. It can be used for other use-cases. There is a
bug / missing feature(?) in the Redis client breaking the VectorStore
implementation. I opened an issue at the client library too
(redis/redis-py#2888) to fix this. As soon as this is fixed in
`redis-py` library it should be usable there too.

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
danielchalef pushed a commit to danielchalef/langchain that referenced this issue Aug 11, 2023
This change updates the central utility class to recognize a Redis
cluster server after connection and returns an new cluster aware Redis
client. The "normal" Redis client would not be able to talk to a cluster
node because keys might be stored on other shards of the Redis cluster
and therefor not readable or writable.

With this patch clients do not need to know what Redis server it is,
they just connect though the same API calls for standalone and cluster
server.

There are no dependencies added due to this MR.

Remark - with current redis-py client library (4.6.0) a cluster cannot
be used as VectorStore. It can be used for other use-cases. There is a
bug / missing feature(?) in the Redis client breaking the VectorStore
implementation. I opened an issue at the client library too
(redis/redis-py#2888) to fix this. As soon as this is fixed in
`redis-py` library it should be usable there too.

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
@dvora-h dvora-h added the bug Bug label Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants