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 7e4f2244-4fd8-4f30-9f61-d1087e4b3292@gmail.com
Whole thread
In response to Deadlock detector fails to activate on a hot standby replica  (Vitaly Davydov <v.davydov@postgrespro.ru>)
Responses Re: Proposal: Conflict log history table for Logical Replication
Re: Deadlock detector fails to activate on a hot standby replica
List pgsql-hackers
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






pgsql-hackers by date:

Previous
From: Bharath Rupireddy
Date:
Subject: Re: REPACK (CONCURRENTLY) fails with wrong error for materialized views
Next
From: Vitaly Davydov
Date:
Subject: Re: Deadlock detector fails to activate on a hot standby replica