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

ability to specify health_check_interval for redis #184

Closed
L1ghtman2k opened this issue Dec 20, 2019 · 2 comments
Closed

ability to specify health_check_interval for redis #184

L1ghtman2k opened this issue Dec 20, 2019 · 2 comments

Comments

@L1ghtman2k
Copy link

L1ghtman2k commented Dec 20, 2019

I am currently running in issue where my Django web app periodically loses connection with my Redis. This seems due to the issue discussed in redis/redis-py#1140

something like the health_check_interval option would allow such a connection failure to be fixed.

@L1ghtman2k
Copy link
Author

Will reopen after a bit more research

@mlissner
Copy link

Hi, just thought I'd check on this one. I'm getting an error from django in production that says:

ConnectionResetError: [Errno 104] Connection reset by peer
  File "redis/connection.py", line 396, in read_response
    bufflen = recv_into(self._sock, self._buffer)
  File "redis/_compat.py", line 61, in recv_into
    return sock.recv_into(*args, **kwargs)

ConnectionError: Error while reading from socket: (104, 'Connection reset by peer')
  File "django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/utils/decorators.py", line 141, in _wrapped_view
    result = middleware.process_request(request)
  File "django/middleware/cache.py", line 133, in process_request
    cache_key = get_cache_key(request, self.key_prefix, 'GET', cache=self.cache)
  File "django/utils/cache.py", line 362, in get_cache_key
    headerlist = cache.get(cache_key)
  File "redis_cache/backends/base.py", line 30, in wrapped
    return method(self, client, key, *args, **kwargs)
  File "redis_cache/backends/base.py", line 260, in get
    return self._get(client, key, default)
  File "redis_cache/backends/base.py", line 248, in _get
    value = client.get(key)
  File "redis/client.py", line 1264, in get
    return self.execute_command('GET', name)
  File "redis/client.py", line 775, in execute_command
    return self.parse_response(connection, command_name, **options)
  File "redis/client.py", line 789, in parse_response
    response = connection.read_response()
  File "redis/connection.py", line 637, in read_response
    response = self._parser.read_response()
  File "redis/connection.py", line 408, in read_response
    raise ConnectionError("Error while reading from socket: %s" %

The issue mentioned above seems to indicate that it could solve this problem. I think the feature should be easy to add, with the caveat that you'll need to either require redis-py > 3.3.0 or would need to handle the error when the health_check_interval was missing.

There's more about this in redis-py's readme. Seems harmless to add this feature?

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