Skip to content

Fix Redis TryAcquireAsync handling for disconnected databases#283

Open
teesofttech wants to merge 1 commit into
madelson:masterfrom
teesofttech:fix/242-redis-unavailability-vs-lock-contention
Open

Fix Redis TryAcquireAsync handling for disconnected databases#283
teesofttech wants to merge 1 commit into
madelson:masterfrom
teesofttech:fix/242-redis-unavailability-vs-lock-contention

Conversation

@teesofttech

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings July 24, 2026 18:26
@teesofttech

teesofttech commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

@madelson can you review this PR, please, for this issue: #242

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Redis TryAcquireAsync behavior in RedLock when one or more IDatabase instances are disconnected (where StackExchange.Redis may backlog operations instead of failing fast), ensuring disconnected cases surface promptly and correctly without masking real underlying faults.

Changes:

  • Update RedLockAcquire.WaitForAcquireAsync to properly propagate the synthetic “disconnected database” fault when it becomes decisive and no real faulted/canceled acquire tasks exist.
  • Adjust the disconnected-database decisiveness logic so a single disconnected database is immediately decisive in the single-server scenario.
  • Add CI tests covering: single-db disconnect throws, synthetic disconnect does not mask a real fault, and single-db contention returns null.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/DistributedLock.Tests/Tests/Redis/RedisDistributedLockTest.cs Adds targeted CI tests validating TryAcquireAsync outcomes for disconnected and contended Redis database scenarios.
src/DistributedLock.Redis/RedLock/RedLockAcquire.cs Fixes fault propagation for synthetic disconnect faults and refines decisiveness logic for single-database acquisition.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants