pglock
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pglock | 1.0.0 | UTIL | PostgreSQL | SQL |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4140 | pglock | No | No | No | Yes | No | No | pglock |
| Related | pg_cron pg_task pg_durable pg_background pg_retry pg_later pgmq pg_dispatch ulak omni_worker pg_cron |
|---|
Packaging patches the upstream pgmb.control mismatch and installs the extension as pglock.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0.0 | 1817161514 | pglock | pg_cron |
| RPM | PIGSTY | 1.0.0 | 1817161514 | pglock_$v | pg_cron_$v |
| DEB | PIGSTY | 1.0.0 | 1817161514 | postgresql-$v-pglock | postgresql-$v-cron |
Build
You can build the RPM / DEB packages for pglock using pig build:
Install
You can install pglock directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
Usage
- Source: README
pglock is a lightweight distributed lock service implemented inside PostgreSQL. It stores lock state in pglock.locks and uses TTL-based cleanup for stale rows.
Create The Extension
The upstream README lists PostgreSQL 9.1+ and plpgsql as requirements.
Acquire And Release Locks
pglock.lock(id, resource) returns true if the lock is acquired and false if another process already holds it. pglock.unlock(id, resource) is documented as idempotent.
Isolation And Expiration
The README recommends serializable isolation for correctness under concurrency:
Stale locks are expired with:
The documented default TTL is 5 minutes. If pg_cron is available, the README says pglock.ttl() can be scheduled every minute.
Lock Table
The upstream schema is pglock.locks with columns id, resource, locked, ttl, created_at, and updated_at. The primary key is (id, resource).
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)