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

Unable to use redisearch on cluster #412

Open
XChikuX opened this issue Nov 5, 2022 · 4 comments · May be fixed by #550
Open

Unable to use redisearch on cluster #412

XChikuX opened this issue Nov 5, 2022 · 4 comments · May be fixed by #550
Assignees

Comments

@XChikuX
Copy link

XChikuX commented Nov 5, 2022

Hi Everyone,

I've been trying out redis-om and I like the simplicity it offers. Thank you for taking the time to write it.

I have run into an issue though. When trying to run the following line of code

Customer.find(Customer.age == 38).all()

The above line of code works fine for a single redis instance. However, in cluster mode which redisearch should be using RSCoordinator under the hood I get redis moved errors.

redis.exceptions.ResponseError: MOVED 14592 10.9.9.6:7003

I have made sure to run: Migrator.run()

And I don't see what other issue I could have run into other than RSCoordinator not responding as its supposed in the redis-om backend. I come to this conclusion since save() & get() work just fine.

@XChikuX
Copy link
Author

XChikuX commented Feb 10, 2023

Just checking in since its been 3 months. Any movement on this?

@jkuehnemundt
Copy link

I unfortunately also have this problem when using a cluster. Is there already a solution for this?

@jrwagz
Copy link

jrwagz commented Jun 26, 2023

I too am trying to get RediSearch with Python OM working on a Redis Cluster. However I ran into this problem a different way.

I was setting the database connection in my model via it's Meta class as follows:

from redis import RedisCluster

class MyModel(JsonModel):
    field: str = Field(index=True)

    class Meta:
        database = RedisCluster(
            host=os.environ["REDIS_DB_HOST"],
            port=os.environ["REDIS_DB_PORT"],
            username=os.environ["REDIS_DB_USER"],
            password=os.environ["REDIS_DB_PASS"],
        )

And when I try to just run Migrator().run I get the following error:

Traceback (most recent call last):
  File ".../debug_model_search.py", line 9, in <module>
    Migrator().run()
  File ".../site-packages/redis_om/model/migrations/migrator.py", line 165, in run
    migration.run()
  File ".../site-packages/redis_om/model/migrations/migrator.py", line 76, in run
    self.create()
  File ".../site-packages/redis_om/model/migrations/migrator.py", line 82, in create
    create_index(self.conn, self.index_name, self.schema, self.hash)
  File ".../site-packages/redis_om/model/migrations/migrator.py", line 43, in create_index
    db_number = conn.connection_pool.connection_kwargs.get("db")
AttributeError: 'RedisCluster' object has no attribute 'connection_pool'

However, if I instead replace the database setup as follows, then the Migrator seems to work just fine:

from redis import Redis

class MyModel(JsonModel):
    field: str = Field(index=True)

    class Meta:
        database = Redis(
            host=os.environ["REDIS_DB_HOST"],
            port=os.environ["REDIS_DB_PORT"],
            username=os.environ["REDIS_DB_USER"],
            password=os.environ["REDIS_DB_PASS"],
        )

Could it be as simple as the fact that the Python OM implementation doesn't support the RedisCluster connection (https://github.com/redis/redis-py/blob/9f503578d1ffed20d63e8023bcd8a7dccd15ecc5/redis/cluster.py#L421), but only supports the Redis connection (https://github.com/redis/redis-py/blob/9f503578d1ffed20d63e8023bcd8a7dccd15ecc5/redis/client.py#L852) instead?

@XChikuX
Copy link
Author

XChikuX commented Jun 26, 2023

Very possible. @chayim or @dvora-h will have to pitch in for us to be sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants