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 [email protected] in commits with
my personal email [email protected] that suits better for me.
With best regards,
Vitaly Davydov
[email protected] (aka [email protected])
[email protected]