Re: Deadlock detector fails to activate on a hot standby replica - Mailing list pgsql-hackers

From Vitaly Davydov
Subject Re: Deadlock detector fails to activate on a hot standby replica
Date
Msg-id e7531fbd-9608-4057-804a-7ac6e52ac198@gmail.com
Whole thread
In response to Re: Deadlock detector fails to activate on a hot standby replica  (Vitaly Davydov <vitprof@gmail.com>)
Responses Re: Truncate logs by max_log_size
Re: Deadlock detector fails to activate on a hot standby replica
List 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.davydov@postgrespro.ru in commits with
> my personal email vitprof@gmail.com that suits better for me.

With best regards,
Vitaly Davydov
vitprof@gmail.com (aka v.davydov@postgrespro.ru)
vitcpp@mail.ru

Attachment

pgsql-hackers by date:

Previous
From: Vitaly Davydov
Date:
Subject: Re: Deadlock detector fails to activate on a hot standby replica
Next
From: Nathan Bossart
Date:
Subject: Re: WAIT FOR command should do some query jumbling