Skip to content

Connection pool doesn't recover from aborts or resets #1772

@Enchufa2

Description

@Enchufa2

Version: 4.0.2

Platform: Python 3.9.7 on Fedora 34

Description: Steps to reproduce:

  1. Make redis establish a connection. For instance, in a local setting:
>>> from redis import Redis()
>>> redis = Redis()
>>> redis.get("something")
  1. Now there's a connection in the pool. The connection gets killed somehow. For instance:
$ sudo ss -K dst [::1] dport = redis
  1. Execute anything else:
>>> redis.get("something")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/***/.local/lib/python3.9/site-packages/redis/commands/core.py", line 1023, in get
    return self.execute_command('GET', name)
  File "/home/***/.local/lib/python3.9/site-packages/redis/client.py", line 1068, in execute_command
    conn = self.connection or pool.get_connection(command_name, **options)
  File "/home/***/.local/lib/python3.9/site-packages/redis/connection.py", line 1179, in get_connection
    if connection.can_read():
  File "/home/***/.local/lib/python3.9/site-packages/redis/connection.py", line 743, in can_read
    return self._parser.can_read(timeout)
  File "/home/***/.local/lib/python3.9/site-packages/redis/connection.py", line 315, in can_read
    return self._buffer and self._buffer.can_read(timeout)
  File "/home/***/.local/lib/python3.9/site-packages/redis/connection.py", line 224, in can_read
    self._read_from_socket(timeout=timeout,
  File "/home/***/.local/lib/python3.9/site-packages/redis/connection.py", line 192, in _read_from_socket
    data = self._sock.recv(socket_read_size)
ConnectionAbortedError: [Errno 103] Software caused connection abort

The same happens if there's a firewall that resets the connection, but then a ConnectionResetError is obtained instead. This doesn't happen with v3.5.3, which automatically detects the loss of connection and sets up a new one.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions