Jump to solution
Details

The Fix

pip install redis==7.1.0

Based on closed redis/redis-py issue #3532 · 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%.

Open PR/Commit
@@ -478,6 +478,7 @@ def lock( lock_class: Optional[Type[Lock]] = None, thread_local: bool = True, + raise_on_release_error: bool = True, ) -> Lock: """
fix.md
Option A — Upgrade to fixed release\npip install redis==7.1.0\nWhen NOT to use: This fix should not be used if raising an exception on lock release is required.\n\n

Why This Fix Works in Production

  • Trigger: I was having trouble using async locks with the context manager because it was failing when exiting the context manager after timeout had expired (even if my…
  • Mechanism: The async lock context manager raised a LockNotOwnedError when exiting after timeout
  • Why the fix works: Adds an option to the async lock context manager to suppress exceptions when the lock is no longer owned upon exiting the context manager, addressing issue #3532. (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

  • The async lock context manager raised a LockNotOwnedError when exiting after timeout
  • Production symptom (often without a traceback): I was having trouble using async locks with the context manager because it was failing when exiting the context manager after timeout had expired (even if my code executed successfully).

Proof / Evidence

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

Discussion

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

“Thank you for your contribution, I am already looking at the PR.”
@petyaslavova · 2025-02-28 · source

Failure Signature (Search String)

  • I was having trouble using async locks with the context manager because it was failing when exiting the context manager after timeout had expired (even if my code executed
  • I would really like not to raise a LockNotOwnedError in the exit of the context manager (if I try to release a lock and it was already "released" then great!).
Copy-friendly signature
signature.txt
Failure Signature ----------------- I was having trouble using async locks with the context manager because it was failing when exiting the context manager after timeout had expired (even if my code executed successfully). I would really like not to raise a LockNotOwnedError in the exit of the context manager (if I try to release a lock and it was already "released" then great!).

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- I was having trouble using async locks with the context manager because it was failing when exiting the context manager after timeout had expired (even if my code executed successfully). I would really like not to raise a LockNotOwnedError in the exit of the context manager (if I try to release a lock and it was already "released" then great!).

What Broke

Users experienced failures when exiting the context manager after lock expiration.

Why It Broke

The async lock context manager raised a LockNotOwnedError when exiting after timeout

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 used if raising an exception on lock release is required.

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/3531

First fixed release: 7.1.0

Last verified: 2026-02-09. 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 used if raising an exception on lock release is required.

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.