Reset waitStart when a lock wait fails - Mailing list pgsql-hackers

From shihao zhong
Subject Reset waitStart when a lock wait fails
Date
Msg-id CAGRkXqQLxZBr-ouVrtaX2utMggi4+TiVMbgH04b_0JLgKryxbA@mail.gmail.com
Whole thread
Responses Re: Reset waitStart when a lock wait fails
List pgsql-hackers
Hi,

Alex and Sami noticed in [1] that RemoveFromWaitQueue() does not clear
PGPROC->waitStart. After lock_timeout, cancel or deadlock the old value
stays until the next lock wait.

It leaks into pg_locks for a short time. The next wait joins the queue
before ProcSleep() stores the new waitStart, and in that window pg_locks
shows the old start time instead of NULL. Backend stopped at ProcSleep()
entry, a few seconds after a lock_timeout:

  pid  | relation |        mode         | granted |           waitstart
 -------+----------+---------------------+---------+-------------------------------
  42442 | t        | AccessExclusiveLock | f       | 2026-09-23 21:01:39.274763-04

With the patch it reads NULL. The patch clears it the same way
ProcWakeup() does, like 70f470314cb did for the grant path. It applies
to 14 and up.

[1] https://postgr.es/m/CAPrb+Q+XN=sNusXiUeWmMo2H7Qgq3Y4uPekSSLkHcnCyf7GhXg@mail.gmail.com

Thanks,
Shihao
Attachment

pgsql-hackers by date:

Previous
From: "zengxx"
Date:
Subject: 回复: Skip a redundant singleton GROUP BY node
Next
From: shihao zhong
Date:
Subject: Re: REPACK (CONCURRENTLY) can silently lose updates when the toast table is rewritten