Re: Reset waitStart when a lock wait fails

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Andrew Krylosov <krylosov(dot)andrew(at)gmail(dot)com>
Cc: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, 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>
Subject: Re: Reset waitStart when a lock wait fails
Date: 2026-09-27 15:51:16
Message-ID: CAGRkXqSvF2PUHCcX4S5WQQLoPmsB_9vHXeYDVp=uROFrVaCZLw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Andrew,

> 1) I think 0001 is not needed anymore once 0002 is applied. With
> 0002, the waiting backend always clears waitStart itself when the wait
> ends at the end of ProcSleep(), or in LockErrorCleanup().
> RemoveFromWaitQueue() is only called from CheckDeadLock() and
> LockErrorCleanup(), and both paths reach one of these new resets.
>
> Maybe it is simpler to merge 0001 and 0002 into one commit?
> They fix the same problem and would be backpatched together.

Agreed, v3 merges them into one patch. The code is the same as v2.

You are right that the RemoveFromWaitQueue() line is no longer needed.
I kept it so it matches ProcWakeup(), since Chao and Michael wanted the
field cleared there. I'm fine with dropping it if Fujii-san prefers. On
14 to 17 there is a third caller, the early deadlock exit in
ProcSleep(), but it runs before waitStart is set, so your point holds
there too.

> 2) 0001 has "Backpatch-through: 14", but 0002 has no such line.

My mistake. v3 has Backpatch-through: 14.

Thanks,
Shihao

Attachment Content-Type Size
v3-0001-Reset-waitStart-when-a-lock-wait-ends.patch application/octet-stream 3.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shihao zhong 2026-09-27 15:53:36 Re: REPACK (CONCURRENTLY) can't complete after ~105M concurrent updates/deletes
Previous Message Mihail Nikalayeu 2026-09-27 14:28:44 Re: Support EXCEPT for TABLES IN SCHEMA publications