Skip to main content

Function: withAdvisoryLock()

withAdvisoryLock<T>(__namedParameters): Promise<T>

Defined in: advisoryLock.ts:30

Runs fn while holding a Postgres session-level advisory lock (pg_advisory_lock), acquired and released on a single dedicated connection.

A naive sequelize.query() lock/unlock pair can land on different pooled backends and try to unlock a lock the current connection never held, so the connection is borrowed once and kept for the whole critical section. The lock is always released on both the success and failure paths.

Type Parameters

Type Parameter
T

Parameters

ParameterType
__namedParametersWithAdvisoryLockOptions<T>

Returns

Promise<T>