mirror of
https://github.com/postgres/postgres.git
synced 2025-10-27 00:12:01 +03:00
Add GUC option to log lock acquisition failures.
This commit introduces a new GUC, log_lock_failure, which controls whether a detailed log message is produced when a lock acquisition fails. Currently, it only supports logging lock failures caused by SELECT ... NOWAIT. The log message includes information about all processes holding or waiting for the lock that couldn't be acquired, helping users analyze and diagnose the causes of lock failures. Currently, this option does not log failures from SELECT ... SKIP LOCKED, as that could generate excessive log messages if many locks are skipped, causing unnecessary noise. This mechanism can be extended in the future to support for logging lock failures from other commands, such as LOCK TABLE ... NOWAIT. Author: Yuki Seino <seinoyu@oss.nttdata.com> Co-authored-by: Fujii Masao <masao.fujii@gmail.com> Reviewed-by: Jelte Fennema-Nio <postgres@jeltef.nl> Discussion: https://postgr.es/m/411280a186cc26ef7034e0f2dfe54131@oss.nttdata.com
This commit is contained in:
@@ -30,6 +30,7 @@ typedef struct PGPROC PGPROC;
|
||||
|
||||
/* GUC variables */
|
||||
extern PGDLLIMPORT int max_locks_per_xact;
|
||||
extern PGDLLIMPORT bool log_lock_failure;
|
||||
|
||||
#ifdef LOCK_DEBUG
|
||||
extern PGDLLIMPORT int Trace_lock_oidmin;
|
||||
@@ -560,7 +561,8 @@ extern LockAcquireResult LockAcquireExtended(const LOCKTAG *locktag,
|
||||
bool sessionLock,
|
||||
bool dontWait,
|
||||
bool reportMemoryError,
|
||||
LOCALLOCK **locallockp);
|
||||
LOCALLOCK **locallockp,
|
||||
bool logLockFailure);
|
||||
extern void AbortStrongLockAcquire(void);
|
||||
extern void MarkLockClear(LOCALLOCK *locallock);
|
||||
extern bool LockRelease(const LOCKTAG *locktag,
|
||||
|
||||
Reference in New Issue
Block a user