Re: Reset waitStart when a lock wait fails

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: 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-25 14:01:00
Message-ID: CAGRkXqSk2p+F+28W-CmOC3=z5s8GCvCE+6UA+tc4haZUqr90Yg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> BTW, ProcWakeup() can reset waitStart before the waiter updates it in
> ProcSleep() (or ResolveRecoveryConflictWithLock() during hot standby)?
> If so, seems waitStart could remain set even after the wait, causing the
same
> issue. To fix this, we should reset waitStart at the end of ProcSleep()
and
> in LockErrorCleanup() as well?

Yes, it happens. I held the waiter at ProcSleep() entry while the holder
committed, and waitStart stayed set after the wait.

v2 attached. 0001 is unchanged. 0002 clears waitStart at the end of
ProcSleep() and in LockErrorCleanup(). The LockErrorCleanup() part is for
a cancel that arrives after the grant, where ProcSleep() errors out before
its end. With 0002 the standby shows the start of the current wait, and
the other cases read NULL.

On 14 to 17, 0002 needs a small context fix
since ResetAwaitedLock() is "lockAwaited = NULL" there.

Thanks,
Shihao

Attachment Content-Type Size
v2-0002-Clear-waitStart-when-the-lock-is-granted-before-i.patch application/octet-stream 2.2 KB
v2-0001-Reset-waitStart-when-a-lock-wait-fails.patch application/octet-stream 1.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Osama Abdul Qader 2026-09-25 14:05:15 Re: Severe performance degradation with concurrent updates due to excessive EvalPlanQual (EPQ) re‑evaluation
Previous Message Viktor Holmberg 2026-09-25 13:52:08 Re: ON CONFLICT DO SELECT returns rows hidden by a view