Jump to solution
Verify

The Fix

pip install redis==7.1.0

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

Production note: Watch p95/p99 latency and retry volume; timeouts can turn into retry storms and duplicate side-effects.

Jump to Verify Open PR/Commit
@@ -24,6 +24,7 @@ * Remove compatibility code for old versions of Hiredis, drop Packaging dependency * The `deprecated` library is no longer a dependency + * Enable Lock for asyncio cluster mode * 4.1.3 (Feb 8, 2022)
repro.py
async def test_aiolock(): from redis.asyncio.lock import Lock as ALock r: redis.asyncio.RedisCluster = aredis() # Async Redis cluster connection counter = 0 async with ALock( redis=r, name="test-lock", timeout=None, sleep=0.01, blocking=True ): counter += 1 assert counter == 1
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: Do not use this fix if the application relies on the blocking behavior of non-async clients.\n\n

Why This Fix Works in Production

  • Trigger: AsyncIO Cluster Mode Lock doesn't work
  • Mechanism: AsyncIO Cluster mode Lock implementation fails due to missing connection_pool attribute in RedisCluster client
  • Why the fix works: Enables AsyncIO cluster mode lock by modifying the Lock implementation to handle the absence of the connection_pool attribute in the AsyncIO cluster client. (first fixed release: 7.1.0).
Production impact:
  • If left unfixed, tail latency can spike under load and surface as timeouts/retries (amplifying incident impact).

Why This Breaks in Prod

  • Shows up under Python 3.10 in real deployments (not just unit tests).
  • AsyncIO Cluster mode Lock implementation fails due to missing connection_pool attribute in RedisCluster client
  • Production symptom (often without a traceback): AsyncIO Cluster Mode Lock doesn't work

Proof / Evidence

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

Verified Execution

We executed the runnable minimal repro in a temporary environment and captured exit codes + logs.

  • Status: PASS
  • Ran: 2026-02-11T16:52:29Z
  • Package: redis
  • Fixed: 7.1.0
  • Mode: fixed_only
  • Outcome: ok
Logs
affected (exit=None)
fixed (exit=0)

Discussion

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

“**Version**: 4.3.x - 4.4.0rc2 **Platform**: Python 3.10 on Ubuntu 20.04 **Description**: AsyncIO Cluster mode doesn't seem to support Lock Reproducible code is this Log is as follow Also, I think we can typehint async version of Lock to acc”
Issue thread · issue description · source

Failure Signature (Search String)

  • AsyncIO Cluster Mode Lock doesn't work
  • **Description**: AsyncIO Cluster mode doesn't seem to support Lock
Copy-friendly signature
signature.txt
Failure Signature ----------------- AsyncIO Cluster Mode Lock doesn't work **Description**: AsyncIO Cluster mode doesn't seem to support Lock

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- AsyncIO Cluster Mode Lock doesn't work **Description**: AsyncIO Cluster mode doesn't seem to support Lock

Minimal Reproduction

repro.py
async def test_aiolock(): from redis.asyncio.lock import Lock as ALock r: redis.asyncio.RedisCluster = aredis() # Async Redis cluster connection counter = 0 async with ALock( redis=r, name="test-lock", timeout=None, sleep=0.01, blocking=True ): counter += 1 assert counter == 1

Environment

  • Python: 3.10

What Broke

AsyncIO Cluster mode Lock raises AttributeError during execution, causing test failures.

Why It Broke

AsyncIO Cluster mode Lock implementation fails due to missing connection_pool attribute in RedisCluster client

Fix Options (Details)

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

pip install redis==7.1.0

When NOT to use: Do not use this fix if the application relies on the blocking behavior of non-async clients.

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

Option D — Guard side-effects with OnceOnly Guardrail for side-effects

Mitigate duplicate external side-effects under retries/timeouts/agent loops by gating the operation before calling external systems.

  • Place OnceOnly between your code/agent and real side-effects (Stripe, emails, CRM, APIs).
  • Use a stable key per side-effect (e.g., customer_id + action + idempotency_key).
  • Fail-safe: configure fail-open vs fail-closed based on blast radius and spend risk.
Show example snippet (optional)
onceonly.py
from onceonly import OnceOnly import os once = OnceOnly(api_key=os.environ["ONCEONLY_API_KEY"], fail_open=True) # Stable idempotency key per real side-effect. # Use a request id / job id / webhook delivery id / Stripe event id, etc. event_id = "evt_..." # replace key = f"stripe:webhook:{event_id}" res = once.check_lock(key=key, ttl=3600) if res.duplicate: return {"status": "already_processed"} # Safe to execute the side-effect exactly once. handle_event(event_id)

See OnceOnly SDK

When NOT to use: Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.

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

First fixed release: 7.1.0

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

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not use this fix if the application relies on the blocking behavior of non-async clients.
  • Do not use this to hide logic bugs or data corruption. Use it to block duplicate external side-effects and enforce tool permissions/spend caps.

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

  • Add a stress test that runs high-concurrency workloads and fails on thread dumps / blocked locks.
  • Enable watchdog dumps in prod (faulthandler, thread dump endpoint) to capture deadlocks quickly.
  • 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.