Re: Deadlock detector fails to activate on a hot standby replica

From: JoongHyuk Shin <sjh910805(at)gmail(dot)com>
To: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Cc: Vitaly Davydov <vitprof(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Subject: Re: Deadlock detector fails to activate on a hot standby replica
Date: 2026-08-28 08:17:25
Message-ID: CACSdjfPcEFxBXdHYQab-2L6krrPAvZRSQdRhejw9E0HgE_c=wg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ewan Young 2026-08-28 08:29:57 Re: REPACK (CONCURRENTLY) fails when replica identity index is dropped
Previous Message Nazir Bilal Yavuz 2026-08-28 08:16:15 Re: [PATCH] Use streaming read I/O in sample scans