Jump to solution
Verify

The Fix

pip install redis==7.1.0

Based on closed redis/redis-py issue #2866 · PR/commit linked

Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.

Jump to Verify Open PR/Commit
@@ -284,6 +284,9 @@ def set_parser(self, parser_class: Type[BaseParser]) -> None: async def connect(self): """Connects to the Redis server if not already connected""" + await self.connect_check_health(check_health=True) + + async def connect_check_health(self, check_health: bool = True):
repro.py
import asyncio import traceback import uuid from redis.asyncio import Redis, Sentinel def get_redis_conn(): sentinel_connection = Sentinel( [('rfs-plaid', 26379)], db=6, health_check_interval=2, retry_on_timeout=True, ) return sentinel_connection.master_for( 'mymaster', redis_class=Redis, decode_responses=True ) async def check_connection_limit_bug(): conn = get_redis_conn() await conn.config_set('maxclients', 1000) try: await consume_client_connections() while True: await conn.get('test') await asyncio.sleep(2) finally: await conn.config_set('maxclients', 10000) pass async def consume_client_connections(): for i in range(1010): try: conn = get_redis_conn() unique_value = str(uuid.uuid4()) unique_key = f'liveness-check:{unique_value}' await conn.setex( name=unique_key, time=60, value=unique_value ) await conn.getdel( name=unique_key, ) except: print(traceback.format_exc()) asyncio.run(check_connection_limit_bug())
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\npip install redis==7.1.0\nWhen NOT to use: This fix should not be applied if the application relies on the previous health check behavior.\n\n

Why This Fix Works in Production

  • Trigger: response = await self._parser.read_response(
  • Mechanism: The health check mechanism caused infinite recursion when the maximum number of clients was exceeded
  • Why the fix works: Fixed infinitely recursive health checks that caused a maximum recursion depth error when the maximum number of clients was exceeded with Sentinel. (first fixed release: 7.1.0).
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • Shows up under Python 3.11.4 in real deployments (not just unit tests).
  • The health check mechanism caused infinite recursion when the maximum number of clients was exceeded
  • Surfaces as: Traceback (most recent call last):

Proof / Evidence

  • GitHub issue: #2866
  • Fix PR: https://github.com/redis/redis-py/pull/3557
  • First fixed release: 7.1.0
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-08
  • Confidence: 0.75
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.29

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“@petyaslavova here's the (another) repro: https://github.com/excitoon/andy, both sync and async versions affected”
@excitoon · 2025-03-12 · repro detail · source
“The sudden increase in connection usage is likely due to https://github.com/redis/redis-py/pull/2755 That will hopefully be fixed by fixing issue https://github.com/redis/redis-py/issues/2831 This is a separate error…”
@rad-pat · 2023-07-28 · source
“@rad-pat I confirm that #2831 is fixed on master version.”
@nsteinmetz · 2023-08-06 · source
“@rad-pat Can you confirm that now you don't get this error (with code from master) and we can close this issue?”
@dvora-h · 2023-08-29 · source

Failure Signature (Search String)

  • response = await self._parser.read_response(

Error Message

Stack trace
error.txt
Error Message ------------- Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/redis/asyncio/connection.py", line 778, in read_response response = await self._parser.read_response( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/redis/asyncio/connection.py", line 411, in read_response await self.read_from_socket() File "/usr/local/lib/python3.11/site-packages/redis/asyncio/connection.py", line 392, in read_from_socket buffer = await self._stream.read(self._read_size) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/streams.py", line 690, in read await self._wait_for_data('read') File "/usr/local/lib/python3.11/asyncio/streams.py", line 520, in _wait_for_data self._waiter = self._loop.create_future() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "uvloop/loop.pyx", line 1412, in uvloop.loop.Loop.create_future File "uvloop/loop.pyx", line 718, in uvloop.loop.Loop._new_future File "/usr/local/lib/python3.11/traceback.py", line 231, in extract_stack stack = StackSummary.extract(walk_stack(f), limit=limit) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/traceback.py", line 393, in extract return klass._extract_from_extended_frame_gen( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr ... (truncated) ...

Minimal Reproduction

repro.py
import asyncio import traceback import uuid from redis.asyncio import Redis, Sentinel def get_redis_conn(): sentinel_connection = Sentinel( [('rfs-plaid', 26379)], db=6, health_check_interval=2, retry_on_timeout=True, ) return sentinel_connection.master_for( 'mymaster', redis_class=Redis, decode_responses=True ) async def check_connection_limit_bug(): conn = get_redis_conn() await conn.config_set('maxclients', 1000) try: await consume_client_connections() while True: await conn.get('test') await asyncio.sleep(2) finally: await conn.config_set('maxclients', 10000) pass async def consume_client_connections(): for i in range(1010): try: conn = get_redis_conn() unique_value = str(uuid.uuid4()) unique_key = f'liveness-check:{unique_value}' await conn.setex( name=unique_key, time=60, value=unique_value ) await conn.getdel( name=unique_key, ) except: print(traceback.format_exc()) asyncio.run(check_connection_limit_bug())

Environment

  • Python: 3.11.4

What Broke

Application experienced maximum recursion depth errors leading to service outages.

Why It Broke

The health check mechanism caused infinite recursion when the maximum number of clients was exceeded

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install redis==7.1.0

When NOT to use: This fix should not be applied if the application relies on the previous health check behavior.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/redis/redis-py/pull/3557

First fixed release: 7.1.0

Last verified: 2026-02-08. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix should not be applied if the application relies on the previous health check behavior.

Verify Fix

verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Make timeouts explicit and test them (unit + integration) to avoid silent behavior changes.
  • Instrument retries (attempt count + reason) and alert on spikes to catch dependency slowdowns.

Version Compatibility Table

VersionStatus
7.1.0 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.