Skip to content

Title: RedisLockProvider fails to acquire locks during Redis endpoint redistribution #1435

Description

@dineshbalani

Describe the bug
When using RedisLockProvider with a service discovery system that periodically redistributes Redis endpoints distributed lock acquisition randomly fails with:

RedLockNet.Exceptions.RedisException: The specified endpoint is not defined

The error is intermittent — sometimes lock acquisition succeeds through the endpoint redistribution event, sometimes it fails. Pod restart always resolves the issue temporarily

To Reproduce
Steps to reproduce the behavior:

  • Deploy application using UseRedisLocking(connectionString), where Redis endpoints are redistributed dynamically by a service discovery system

  • Let the application run until a Redis endpoint redistribution event occurs

  • Observe RedLockNet.Exceptions.RedisException thrown from RedisLockProvider.AcquireLock()

  • Restart the pod — error resolves immediately

Expected behavior
[RedisLockProvider.AcquireLock()] should validate the connection state before attempting to create a distributed lock. If the cached IConnectionMultiplexer is disconnected (stale), the provider should reconnect before proceeding rather than using a zombie connection that has no valid endpoints registered in RedLock.

Currently AcquireLock() only checks if (_redlockFactory == null) but never validates _multiplexer.IsConnected.
During endpoint redistribution, StackExchange.Redis begins async background reconnection, but AcquireLock() doesn't wait — it attempts to use the still-disconnected multiplexer immediately, causing RedLock to fail with "endpoint not defined".

Additional context
WorkflowCore: 3.14.0
StackExchange.Redis: 2.8.47
.NET: 8.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions