Skip to content

fix: handle expired Redis lock release gracefully#2060

Merged
PawelPeczek-Roboflow merged 4 commits intomainfrom
bug/dg-319-error-cannot-release-a-lock-thats-no-longer-owned
Mar 6, 2026
Merged

fix: handle expired Redis lock release gracefully#2060
PawelPeczek-Roboflow merged 4 commits intomainfrom
bug/dg-319-error-cannot-release-a-lock-thats-no-longer-owned

Conversation

@rafel-roboflow
Copy link
Contributor

@rafel-roboflow rafel-roboflow commented Mar 2, 2026

Resolves dg-319

When a redis lock's TTL expires before the code inside the lock finishes executing, calling release() throws "cannot release a lock that's no longer owned".

What does this PR do?

we want to avoid showing this error in the frontend.

image

Related Issue(s):

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Testing

  • I have tested this change locally

Test details:

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • I have updated the documentation accordingly (if applicable)

Additional Context


Note

Low Risk
Small, localized change to lock cleanup behavior; main risk is potentially masking unexpected premature lock expiry (now surfaced only via a warning log).

Overview
BaseCache.lock now catches redis.exceptions.LockNotOwnedError when releasing a lock and logs a warning instead of raising, preventing failures/noisy errors when the lock TTL expires before the protected work completes.

Written by Cursor Bugbot for commit 1557dad. This will update automatically on new commits. Configure here.

When a redis lock's TTL expires before the code inside the
lock finishes executing, calling release() throws "cannot release a
lock that's no longer owned".
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@rafel-roboflow rafel-roboflow enabled auto-merge (squash) March 5, 2026 21:27
@PawelPeczek-Roboflow PawelPeczek-Roboflow merged commit a284c8e into main Mar 6, 2026
45 checks passed
@PawelPeczek-Roboflow PawelPeczek-Roboflow deleted the bug/dg-319-error-cannot-release-a-lock-thats-no-longer-owned branch March 6, 2026 17:24
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

Successfully merging this pull request may close these issues.

3 participants