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

[Bug]: redis cache storage issues with connecting to remote cluster #486

Closed
a9raag opened this issue Jul 14, 2023 · 4 comments
Closed

[Bug]: redis cache storage issues with connecting to remote cluster #486

a9raag opened this issue Jul 14, 2023 · 4 comments

Comments

@a9raag
Copy link
Contributor

a9raag commented Jul 14, 2023

Current Behavior

The GPTCache server works fine while using the local Redis instance but, I am getting a connection error while trying to connect to Remote Redis Instance

  File "E:\dev\gptcache\gptcache_server\server.py", line 215, in <module>
    main()
  File "E:\dev\gptcache\gptcache_server\server.py", line 178, in main
    init_conf = init_similar_cache_from_config(config_dir=args.cache_config_file)
  File "E:\dev\gptcache\gptcache\adapter\api.py", line 221, in init_similar_cache_from_config
    data_manager = manager_factory(**storage_config)
  File "E:\dev\gptcache\gptcache\manager\factory.py", line 74, in manager_factory
    s = CacheBase(name=scalar, **scalar_params)
  File "E:\dev\gptcache\gptcache\manager\scalar_data\__init__.py", line 14, in CacheBase
    return scalar_manager.CacheBase.get(name, **kwargs)
  File "E:\dev\gptcache\gptcache\manager\scalar_data\manager.py", line 99, in get
    return RedisCacheStorage(
  File "E:\dev\gptcache\gptcache\manager\scalar_data\redis_storage.py", line 199, in __init__
    Migrator().run()
  File "D:\Dev\venv\lib\site-packages\redis_om\model\migrations\migrator.py", line 163, in run
    self.detect_migrations()
  File "D:\Dev\venv\lib\site-packages\redis_om\model\migrations\migrator.py", line 118, in detect_migrations
    conn.ft(cls.Meta.index_name).info()
  File "D:\Dev\venv\lib\site-packages\redis\commands\search\commands.py", line 370, in info
    res = self.execute_command(INFO_CMD, self.index_name)
  File "D:\Dev\venv\lib\site-packages\redis\client.py", line 1266, in execute_command
    conn = self.connection or pool.get_connection(command_name, **options)
  File "D:\Dev\venv\lib\site-packages\redis\connection.py", line 1461, in get_connection
    connection.connect()
  File "D:\Dev\venv\lib\site-packages\redis\connection.py", line 713, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 10061 connecting to localhost:6379. No connection could be made because the target machine actively refused it.

Expected Behavior

GPTCache server should start without errors

Steps To Reproduce

Step 1: Update the cache_config_file and set 
storage_config:
    data_dir:
        gptcache_data
    manager:
        redis,faiss
    scalar_params:
        # Set scalar storage related params here
        url: "URL_TO_REMOTE_INSTACE:PORT"

Step 2: Start GPT Cache Server 

Environment

Mac, Windows, Linux

Anything else?

No response

@SimFG
Copy link
Collaborator

SimFG commented Jul 14, 2023

@a9raag can you get me the error message?

@a9raag
Copy link
Contributor Author

a9raag commented Jul 14, 2023

@SimFG added the error trace.

@a9raag
Copy link
Contributor Author

a9raag commented Jul 14, 2023

@SimFG I know where it is coming from.
Migrator.run() creates Indexes necessary for Redis Search.
But during the creation, it picks up localhost connection from the pool instead of the cluster collection.

I have a solution:
We can modify the connection to be used in the instance of RedisModel by updating the Meta class.
While calling the get_models method provide the Redis connection as a parameter and this will be used to update the Meta class for all RedisModels

sre-ci-robot pushed a commit that referenced this issue Jul 14, 2023
…487)

* [mod] provide redis_connection while model creation for consistency

Signed-off-by: Anurag Wagh <a9raag@gmail.com>

* [add] documentation for `get_models` method

Signed-off-by: Anurag Wagh <a9raag@gmail.com>

* [add] set redis connection details to common variable for unit test

Signed-off-by: Anurag Wagh <a9raag@gmail.com>

* [add] provide redis connection for embedded model

Signed-off-by: Anurag Wagh <a9raag@gmail.com>

* [add] add doc string for Counter class

Signed-off-by: Anurag Wagh <a9raag@gmail.com>

---------

Signed-off-by: Anurag Wagh <a9raag@gmail.com>
@SimFG
Copy link
Collaborator

SimFG commented Jul 14, 2023

@a9raag Thank your pull request!!!

@SimFG SimFG closed this as completed Jul 14, 2023
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

No branches or pull requests

2 participants