Class RedbDistributedLock
Distributed lock on redb storage.
One record per (cluster, group, lock) is guaranteed by the database: the key
ValueUnique = "{cluster}:{group}:{lockName}" sits under the per-scheme partial unique
index, so a concurrent first-create loses with
instead of leaving a duplicate. Ownership transitions stay CAS: transaction + row-level
lock (LockForUpdateAsync) + re-read, with the epoch as the fence.
The group comes with every call; the cluster is this process's ,
so an equally named group of another cluster on the same database holds its own locks.
Shared by and ClusteredRoutePolicy.
public sealed class RedbDistributedLock : IDistributedLock
Inheritance
Implements
Methods
ReleaseAsync(string, string, string, CancellationToken)
Releases a lock owned by the specified node. Deletes the lock record.
public Task ReleaseAsync(string lockName, string ownerNodeId, string groupName, CancellationToken ct = default)
RenewAsync(string, string, string, long, int, CancellationToken)
Renews a lock owned by the specified node. Verifies epoch fencing.
public Task<bool> RenewAsync(string lockName, string ownerNodeId, string groupName, long expectedEpoch, int ttlSeconds, CancellationToken ct = default)
TryAcquireAsync(string, string, string, int, CancellationToken)
Attempts to acquire or renew a named lock. Atomic via row-level lock.
public Task<LockResult> TryAcquireAsync(string lockName, string ownerNodeId, string groupName, int ttlSeconds, CancellationToken ct = default)