| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | shihao zhong <zhong950419(at)gmail(dot)com> |
| Cc: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Alex Shapalov <shapalov(at)gmail(dot)com>, Sami Imseih <samimseih(dot)pg(at)gmail(dot)com>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
| Subject: | Re: Reset waitStart when a lock wait fails |
| Date: | 2026-09-24 02:37:12 |
| Message-ID: | 8BC31B6F-5A20-45DC-9D7C-F65293488E08@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Sep 24, 2026, at 09:30, shihao zhong <zhong950419(at)gmail(dot)com> wrote:
>
> 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
> <v1-0001-Reset-waitStart-when-a-lock-wait-fails.patch>
Looks good to me. Once proc->waitLock is cleared, proc->waitStart no longer describes an active wait, so clearing it at the same time seems right.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ajin Cherian | 2026-09-24 02:40:12 | Re: table-write trigger can bypass ATPrepChangePersistence |
| Previous Message | shihao zhong | 2026-09-24 01:51:55 | Re: Add a permission check to pg_stat_get_backend_subxact() |