pglock

package
v0.138.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package pglock holds Postgres session advisory locks outside the holder's pool, so the holder's work may use every connection of it. A free key is taken on one session shared by every lock the process holds through a pool; only a key someone already holds is waited for on a connection of its own, so extra connections follow contention, not the number of locks held.

Index

Constants

This section is empty.

Variables

View Source
var ErrContended = errors.New("pglock: acquisition budget expired; retry")

ErrContended asks callers to retry through their existing request or job path.

Functions

func Acquire

func Acquire(ctx context.Context, pool *pgxpool.Pool, key string, wait bool) (release func(), ok bool, err error)

Acquire locks key against every other holder, in this process or another. Without wait it returns ok=false while anyone else holds key; with it, it waits in Postgres's queue for key, where Postgres detects deadlocks.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL