Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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.sentinel.SlaveNotFoundError: No slave found for 'mymaster' #248

Closed
alelomonaco opened this issue Dec 20, 2023 · 0 comments
Closed

Comments

@alelomonaco
Copy link

Name and Version
redis: 7.2.3
dogpile.cache: 1.2.2
redis-py: 5.0.1

What steps will reproduce the bug?

Deploy a Redis cluster with sentinel and auth enabled, create a script to call sentinel host and retrieve data from cache:

import dogpile.cache
import time
import logging
import redis

# Set the log level to DEBUG for Dogpilecache
logging.basicConfig(level=logging.DEBUG)

# Create a Dogpilecache region
cache_region = dogpile.cache.make_region().configure(
    'dogpile.cache.redis_sentinel',
    arguments={
        'sentinels': [
            ['redis-cluster', 26379],
        ],
        'sentinel_kwargs': {
            'password': 'mypassword',
        }
    }
)


def get_data_from_cache(key):
    # Try retrieving data from cache
    data = cache_region.get(key)

    if data is not None:
        print(f"Data found in cache: {data}")
    else:
        print("Data not found in cache")
        # Simulating a time-consuming operation to fetch the data
        time.sleep(2)
        data = f"Sample data for {key}"
        # Store the data in cache for future use
        cache_region.set(key, data)
        print(f"Data stored in cache: {data}")

    return data


# Perform data retrieval using Dogpilecache
print(redis.__version__)
result = get_data_from_cache("example_key")
print(f"Final result: {result}")

Are you using any custom parameters or values?
I'm sure about every parameter because without auth, script works as expected, the only parameter I cannot trust is password in sentinel_kwargs. I'm also sure that problem is on dogpile.cache because from the same client it works with redis-cli or with a python script like this:

import redis

# Create a Redis Sentinel connection
sentinel = redis.Redis(
    host='redis-cluster',
    port=26379,
    password='mypassword',
    decode_responses=True
)

# Get the replicas (slaves) of the master
replicas = sentinel.sentinel_slaves('mymaster')

# Iterate through replicas and print their IP and port
for replica in replicas:
    replica_host = replica['ip']
    replica_port = replica['port']
    print(f"Replica: {replica_host}:{replica_port}")

What is the expected behavior?
same output obtained when auth is disabled:
5.0.1
Data found in cache: <dogpile.cache.api.NoValue object>
Final result: <dogpile.cache.api.NoValue object>

What do you see instead?
redis.sentinel.SlaveNotFoundError: No slave found for 'mymaster

Additional information
Redis cluster is deployed through bitnami helm chart.
I've tried different version of dogpile.cache (1.1.8 and 1.1.0), same result.

I've tried to add decode_responses parameter, same result.
Network and name resolution are ok. It works without auth and with auth enable but without dogpile.cache (like redis-cli and redis-py).

@sqlalchemy sqlalchemy locked and limited conversation to collaborators Dec 20, 2023
@zzzeek zzzeek converted this issue into discussion #249 Dec 20, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant