Thread: pgsql: Add GUC option to log lock acquisition failures.

pgsql: Add GUC option to log lock acquisition failures.

From
Fujii Masao
Date:
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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6d376c3b0d1e79c318d2a1c04097025784e28377

Modified Files
--------------
doc/src/sgml/config.sgml                      |  20 ++++
src/backend/access/heap/heapam.c              |  33 ++++---
src/backend/access/heap/heapam_handler.c      |   4 +-
src/backend/storage/lmgr/lmgr.c               |  33 ++++---
src/backend/storage/lmgr/lock.c               |  55 ++++++++++-
src/backend/storage/lmgr/proc.c               | 129 ++++++++++++++++----------
src/backend/utils/misc/guc_tables.c           |   9 ++
src/backend/utils/misc/postgresql.conf.sample |   1 +
src/include/storage/lmgr.h                    |   5 +-
src/include/storage/lock.h                    |   4 +-
src/include/storage/proc.h                    |   4 +
11 files changed, 211 insertions(+), 86 deletions(-)