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

Yuki Seino <seinoyu@oss.nttdata.com>

From: Seino Yuki <seinoyu@oss.nttdata.com>
To: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2024-10-18T10:07:28Z
Lists: pgsql-hackers

Attachments

> The choice between adding a new GUC or extending the existing one
> (e.g., log_lock_waits)
> is debatable, but I prefer the latter. I'm considering extending 
> log_lock_waits
> to accept a value like "fail". If set to "on" (the current behavior),
> detailed logs are generated when the lock wait time exceeds 
> deadlock_timeout.
> If set to "fail", logs are generated whenever a lock wait fails. If 
> both are
> specified, logs would be triggered when the wait time exceeds
> deadlock_timeout or
> when a lock wait fails.

Thanks for the idea.
Changed log_lock_waits to an enum type and added fail and all.
"off"  : No log message(default).
"on"   : If over deadlock_timeout(the current behavior).
"fail" : If lock failed.
"all"  : All pettern.

I struggled with the name "on," but decided to leave it by 
compatibility.

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