Proposal: adding support for shared distributed locks to the EntityFrameworkCore.Locking.PostgreSQL provider.
In many scenarios we need to allow multiple concurrent readers while keeping writers exclusive – the classic shared/exclusive lock pattern. PostgreSQL advisory locks natively support this via shared locks (e.g., pg_advisory_lock_shared).
Currently there is no way to request a shared distributed lock. I'd like to propose adding support for shared locks.
Here are two proposals:
Proposal 1 – Add a separate AcquireSharedDistributedLock method
public static IDistributedLockHandle AcquireSharedDistributedLock(
this DatabaseFacade database,
string key,
TimeSpan? timeout = null)
Proposal 2 – Introduce a DistributedLockMode enum and overload the existing method
public enum DistributedLockMode
{
Exclusive,
Shared
}
public static IDistributedLockHandle AcquireDistributedLock(
this DatabaseFacade database,
string key,
TimeSpan? timeout = null,
DistributedLockMode mode = DistributedLockMode.Exclusive)
Both proposals only affect the PostgreSQL provider; other providers could implement shared locks according to their own capabilities, or simply ignore the mode and always use exclusive locks, or throw NotSupportedException()
Would you consider adding shared advisory lock support via either of these approaches?
Thanks for your consideration!
Proposal: adding support for shared distributed locks to the EntityFrameworkCore.Locking.PostgreSQL provider.
In many scenarios we need to allow multiple concurrent readers while keeping writers exclusive – the classic shared/exclusive lock pattern. PostgreSQL advisory locks natively support this via shared locks (e.g.,
pg_advisory_lock_shared).Currently there is no way to request a shared distributed lock. I'd like to propose adding support for shared locks.
Here are two proposals:
Proposal 1 – Add a separate
AcquireSharedDistributedLockmethodProposal 2 – Introduce a
DistributedLockModeenum and overload the existing methodBoth proposals only affect the PostgreSQL provider; other providers could implement shared locks according to their own capabilities, or simply ignore the mode and always use exclusive locks, or
throw NotSupportedException()Would you consider adding shared advisory lock support via either of these approaches?
Thanks for your consideration!