| From: | Vitaly Davydov <vitprof(at)gmail(dot)com> |
|---|---|
| To: | JoongHyuk Shin <sjh910805(at)gmail(dot)com>, Xuneng Zhou <xunengzhou(at)gmail(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
| Subject: | Re: Deadlock detector fails to activate on a hot standby replica |
| Date: | 2026-08-31 16:27:37 |
| Message-ID: | e7531fbd-9608-4057-804a-7ac6e52ac198@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Sorry for missed patches. Attached now.
On 8/31/26 19:18, Vitaly Davydov wrote:
> Hi JH Shin,
>
> > I think PinCountWaiterCheckReadyForCleanup() has a window between
> > checking the refcount and setting BM_PIN_COUNT_WAITER. On the master
> > branch, UnpinBufferNoOwner() drops pins without taking the header
> > lock, so the last other pin can go away in that window and the
> > wakeup is lost until the deadlock or standby-limit timeout fires.
> > This looks like the same race that commit 8d85cb889a3 fixed in
> > LockBufferForCleanup(), and the same fix should work here. After
> > publishing the flag, recheck the refcount, and if only our own pin
> > remains, clear the flag and return true.
>
> Agree, thank you.
>
> I made new changes in two commits. In the first commit coming from v7
> patch
> I modified RegisterPinCountWaiter() function to recheck the refcount as
> explained by you. In the second commit I've replaced the duplicate
> code in
> LockBufferForCleanup to register pincount waiter with the call of
> RegisterPinCountWaiter(). The second commit is optional but it fits
> well with
> the current changes.
>
> The patch was rebased to the actual master branch.
>
> P.S. I replaced my old address v(dot)davydov(at)postgrespro(dot)ru in commits with
> my personal email vitprof(at)gmail(dot)com that suits better for me.
With best regards,
Vitaly Davydov
vitprof(at)gmail(dot)com (aka v(dot)davydov(at)postgrespro(dot)ru)
vitcpp(at)mail(dot)ru
| Attachment | Content-Type | Size |
|---|---|---|
| v8-0001-Fix-recovery-conflict-wait-loop-for-buffer-pins-o.patch | text/x-patch | 9.8 KB |
| v8-0002-Use-RegisterPinCountWaiter-in-LockBufferForCleanu.patch | text/x-patch | 2.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nathan Bossart | 2026-08-31 16:28:13 | Re: WAIT FOR command should do some query jumbling |
| Previous Message | Vitaly Davydov | 2026-08-31 16:18:14 | Re: Deadlock detector fails to activate on a hot standby replica |