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

RedisLockStore support for cluster mode #6227

Closed
wochinge opened this issue Jul 16, 2020 · 7 comments
Closed

RedisLockStore support for cluster mode #6227

wochinge opened this issue Jul 16, 2020 · 7 comments
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework area:rasa-oss/lock-stores type:enhancement ✨ Additions of new features or changes to existing ones, should be doable in a single PR

Comments

@wochinge
Copy link
Contributor

wochinge commented Jul 16, 2020

This error happens when using the RedisLockStore with a Redis instance in cluster mode (e.g. https://aws.amazon.com/elasticache/)

@wochinge wochinge added type:enhancement ✨ Additions of new features or changes to existing ones, should be doable in a single PR area:rasa-oss 🎡 Anything related to the open source Rasa framework priority:high labels Jul 16, 2020
@akelad
Copy link
Contributor

akelad commented Aug 7, 2020

Exalate commented:

akelad commented:

from @rgstephens:

After poking around, it looks like we would have to use a separate redis-py-clustered library because the implementation for clusters is so different.

for now i think the user that's having this issue has found a workaround, so let's postpone for now

@alwx alwx added area:rasa-oss/channels 📞 Issues focused around rasas input and output channels area:rasa-oss/lock-stores and removed area:rasa-oss/channels 📞 Issues focused around rasas input and output channels labels Jan 28, 2021
@ghost
Copy link

ghost commented Apr 29, 2021

Exalate commented:

sahajvss commented:

Is there a workaround for this issue?

@ghost
Copy link

ghost commented Apr 30, 2021

Exalate commented:

sahajvss commented:

@wochinge Can you share the workaround you used to make the Redislockstore work in cluster mode?

@mitallast
Copy link

mitallast commented May 26, 2021

Exalate commented:

mitallast commented:

My solution:

requirements.txt

redis-py-cluster==2.1.2

cluster_lock_store.py

import logging
 import json
 from typing import Text, Optional

from rasa.core.lock import TicketLock
 from rasa.core.lock_store import LockStore
 from rasa.utils.endpoints import EndpointConfig

from rediscluster import RedisCluster

logger = logging.getLogger(__name__)

class RedisClusterLockStore(LockStore):
 def __init__(self, endpoint_config: EndpointConfig) -> None:
 self.startup_nodes = endpoint_config.kwargs['startup_nodes']
 self.key_prefix = endpoint_config.kwargs['key_prefix']
 logger.info(f"startup nodes: 

 {self.startup_nodes} 

")
 logger.info(f"key_prefix nodes: 

 {self.key_prefix} 

")
 self.client = RedisCluster(startup_nodes=self.startup_nodes, decode_responses=True)
 super().__init__()

 def lock_key(self, conversation_id: Text) -> Text:
 return self.key_prefix + conversation_id

 def get_lock(self, conversation_id: Text) -> Optional[TicketLock]:
 serialised_lock = self.client.get(self.lock_key(conversation_id))
 if serialised_lock:
 return TicketLock.from_dict(json.loads(serialised_lock))

 def delete_lock(self, conversation_id: Text) -> None:
 deletion_successful = self.client.delete(self.lock_key(conversation_id))
 self._log_deletion(conversation_id, deletion_successful)

 def save_lock(self, lock: TicketLock) -> None:
 self.client.set(self.lock_key(lock.conversation_id), lock.dumps())

endpoints.yml

lock_store:
 type: 'cluster_lock_store.RedisClusterLockStore'
 startup_nodes:

*   host: localhost
     port: 7000
     key_prefix: "chatbot"

@wladneto
Copy link

wladneto commented Feb 1, 2022

Exalate commented:

wladneto commented:

To use redis in cluster "natively" just follow this:

lock_store:
type: redis
db: 0
url: your_URL
port: your_PORT
key_prefix: your bot name or anything

I hope this usefull

@brunohjs
Copy link

brunohjs commented Feb 1, 2022

Exalate commented:

brunohjs commented:

this would be nice to be in the Rasa docs like note

@rasabot-exalate rasabot-exalate added area:rasa-oss type:enhancement ✨ Additions of new features or changes to existing ones, should be doable in a single PR area:rasa-oss 🎡 Anything related to the open source Rasa framework and removed type:enhancement ✨ Additions of new features or changes to existing ones, should be doable in a single PR area:rasa-oss 🎡 Anything related to the open source Rasa framework area:rasa-oss labels Mar 17, 2022 — with Exalate Issue Sync
@rasabot-exalate rasabot-exalate added the type:enhancement ✨ Additions of new features or changes to existing ones, should be doable in a single PR label Mar 21, 2022 — with Exalate Issue Sync
@m-vdb m-vdb removed the priority:low label Dec 7, 2022
@sync-by-unito
Copy link

sync-by-unito bot commented Dec 19, 2022

➤ Maxime Verger commented:

💡 Heads up! We're moving issues to Jira: https://rasa-open-source.atlassian.net/browse/OSS.

From now on, this Jira board is the place where you can browse (without an account) and create issues (you'll need a free Jira account for that). This GitHub issue has already been migrated to Jira and will be closed on January 9th, 2023. Do not forget to subscribe to the corresponding Jira issue!

➡️ More information in the forum: https://forum.rasa.com/t/migration-of-rasa-oss-issues-to-jira/56569.

@m-vdb m-vdb closed this as completed Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework area:rasa-oss/lock-stores type:enhancement ✨ Additions of new features or changes to existing ones, should be doable in a single PR
Projects
None yet
Development

No branches or pull requests

8 participants