Add “FOR UPDATE NOWAIT” lock details to the log.

Yuki Seino <seinoyu@oss.nttdata.com>

From: Seino Yuki <seinoyu@oss.nttdata.com>
To: pgsql-hackers@lists.postgresql.org
Date: 2024-09-13T11:49:36Z
Lists: pgsql-hackers

Attachments

Hello,

I would like to add the information of the PID that caused the failure
when acquiring a lock with "FOR UPDATE NOWAIT".

When "FOR UPDATE" is executed and interrupted by lock_timeout,
xid and PID are output in the logs, but in the case of "FOR UPDATE 
NOWAIT",
no information is output, making it impossible to identify the cause of 
the lock failure.
Therefore, I would like to output information in the logs in the same 
way as
when "FOR UPDATE" is executed and interrupted by lock_timeout.

The patch is attached as well.

Regards,
--
Yuki Seino
NTT DATA CORPORATION

Commits

  1. Rename log_lock_failure GUC to log_lock_failures for consistency.

  2. Add GUC option to log lock acquisition failures.

  3. Split ProcSleep function into JoinWaitQueue and ProcSleep