RedisSentinelBackend doesn't work with "db" number other than 0
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 62/100
Research direction
Start at RedisSentinelBackend and reproduce the configuration with sentinels, service_name, and db: 2; compare its connection behavior with the redis-cli Sentinel example. Check how the backend handles the Sentinel node versus the Redis master. Done means a nonzero db stores cache keys successfully through Redis Sentinel without sending SELECT to a Sentinel node.
Written by the indexing model from the issue text.
Description
Hello,
we are trying to setup RedisSentinelBackend with a non-default db parameter to specify the database of the Redis server where the cache keys should be stored.
However when specifying db parameter other than 0, following error is raised by the Redis client:
redis.exceptions.ResponseError: unknown command `SELECT`, with args beginning with: `2`
Here is our configuration in a simple local setup (we use YAML format, however it shouldn't really matter here):
dogpile_cache:
regions: short_term,jwt_duration,oauth_access_token_duration,hourly
backend: dogpile.cache.redis_sentinel
arguments:
sentinels:
- [127.0.0.1, 26379]
db: 2
distributed_lock: True
thread_local_lock: False
service_name: mymaster
Of course everything works fine when parameter db is removed or set to 0.
I presume what is happening is that Redis client is told to use command SELECT 2 when working with a Sentinel node, while this command is not known by Sentinel.
I can reproduce the issue in redis-cli when connected to a Sentinel node:
127.0.0.1:26379> select 2
(error) ERR unknown command `select`, with args beginning with: `2`,
This seems to be an issue in RedisSentinelBackend of dogpile.cache, because when using e.g. Celery, we are able to specify the db numbers with Sentinel connection strings and keys are then properly created in the db of our choice.
I was also wondering if there could be some workaround for this issue, e.g. using connection_kwargs parameter? I tried passing the db argument to it, however it did not work.
Any help is greatly appreciated, because in our current setup we can't store the cache keys in db 0 of Redis, which currently blocks us from switching to Redis Sentinel setup.
- Dominant language
- Python
- Stars
- 299
- Forks
- 50
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sqlalchemy/dogpile.cache
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
sqlalchemy/dogpile.cache#267 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
sqlalchemy/dogpile.cache#265 · 4 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
sqlalchemy/dogpile.cache#264 · 4 comments ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
sqlalchemy/dogpile.cache#258 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
sqlalchemy/dogpile.cache#243 · 2 comments ·
All issues in sqlalchemy/dogpile.cache
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100