Hi Vitaly, I found one thing while reviewing v7.
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. -- JH Shin >
