pg.ddx.io pgsql-hackers@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Vitaly Davydov <vitprof@gmail.com>
To: JoongHyuk Shin <sjh910805@gmail.com>
To: Xuneng Zhou <xunengzhou@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org, Fujii Masao <masao.fujii@gmail.com>
Subject: Re: Deadlock detector fails to activate on a hot standby replica
Date: Mon, 31 Aug 2026 19:18:14 +0300
Message-ID: <7e4f2244-4fd8-4f30-9f61-d1087e4b3292@gmail.com> (raw )
In-Reply-To: <CACSdjfPcEFxBXdHYQab-2L6krrPAvZRSQdRhejw9E0HgE_c=wg@mail.gmail.com >
References: <44c24dcf-5710-410f-b1b6-d10b315f3d51@postgrespro.ru >
<CABPTF7V2wgjqN6g99uxR_RjGYCLo07e8ogWWTyAqMfzAGg5j_g@mail.gmail.com >
<7b1e8353-3d0a-48a1-bac6-2ac6ca91fbde@postgrespro.ru >
<CABPTF7Xqx=hP7-TeMnXcA76V6Wd9ah3+KjucWVU6FqxS-WQmKg@mail.gmail.com >
<CABPTF7WeTmUXcwXh9WsM8DnU+RB8Hw-U+EpZqkf1Lz8D2rBMaQ@mail.gmail.com >
<5c50d50c-5a9c-4a9e-9592-183cf4de1c80@postgrespro.ru >
<CACSdjfMBDtxiFyA3eEVNJRQi1rufPGEjXOtAQ3qQkVc-P=187w@mail.gmail.com >
<fee569b3-d097-4a22-97a5-11268f0b954a@postgrespro.ru >
<CABPTF7WLTqtAL8DthdoMk5tKiVa22C4Urkbrcw78186eayracQ@mail.gmail.com >
<52971629-dcda-4687-90c8-bbba3ce05636@postgrespro.ru >
<CABPTF7WTeCC60OPGppDuTwR9RpfKq9v4dek1fUyzR6nh7Sympw@mail.gmail.com >
<CAG5KqAbuFFgVfNoDHhiKGsP1twSjBx_VBpyfMsOY9VerPFVfnA@mail.gmail.com >
<CABPTF7WbYDo2vb4e6i33D5=pVkuqwTuxVTM7FMt03mn3gc_3CA@mail.gmail.com >
<CACSdjfPCKNx9txxs5MGEhVUNC4H8nXkANgYAVR0+b8kef_1P+g@mail.gmail.com >
<CACSdjfPcEFxBXdHYQab-2L6krrPAvZRSQdRhejw9E0HgE_c=wg@mail.gmail.com >
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
view thread (43+ messages) latest in thread
Message-ID: <7e4f2244-4fd8-4f30-9f61-d1087e4b3292@gmail.com>
Permalink: ../7e4f2244-4fd8-4f30-9f61-d1087e4b3292@gmail.com/
Also on: postgresql.org/message-id/7e4f2244-4fd8-4f30-9f61-d1087e4b3292@gmail.com
copy link · copy postgr.es
reply Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: vitprof@gmail.com, sjh910805@gmail.com, xunengzhou@gmail.com, masao.fujii@gmail.com
Subject: Re: Deadlock detector fails to activate on a hot standby replica
In-Reply-To: <7e4f2244-4fd8-4f30-9f61-d1087e4b3292@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox