Re: Set 1s WaitLatch timeout if standby limit has expired in ResolveRecoveryConflictWithBufferPin

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Anthony Hsu <erwaman(at)gmail(dot)com>, Xuneng Zhou <xunengzhou(at)gmail(dot)com>, João Rito <joaovictor(dot)rito(at)gmail(dot)com>, shihao zhong <zhong950419(at)gmail(dot)com>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, Dmytro Astapov <dastapov(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Subject: Re: Set 1s WaitLatch timeout if standby limit has expired in ResolveRecoveryConflictWithBufferPin
Date: 2026-11-27 20:42:36
Message-ID: awnkFethz4mAKWY2@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2026-Nov-27, Heikki Linnakangas wrote:

> I looked at this more closely because it conflicted with my "Interrupts vs
> signals" work. I don't see anything wrong, but I started to wonder why we
> use the SIGALRM based timers for the standby timeouts, when we're just
> sleeping on WaitLatch(). WaitLatch() takes a timeout argument, why don't we
> just use that? Would seem much more straightforward.

That sounds reasonable.

> Punching through the encapsulation of ProcWaitForSignal() doesn't really
> bother me, and in fact with my "Interrupts vs signals" rewrite, the
> ProcSendSignal() and ProcWaitForSignal() functions are gone anyway, replaced
> by interrupts. But yeah, you could add a timeout argument to
> ProcWaitForSignal() instead if you'd prefer.

Well, ProcWaitForSignal was added as an abstraction much before we had
latches at all -- back then it was paired with ProcSendSignal. I would
say it's been half-removed already. I don't think we need to keep it;
bare WaitLatch seems fine.

> So, what do you think of the attached? (for master only)

I didn't review in detail, but the removal looks good.

The bit-or'ing of locktag.locktag_type caught my attention, as I don't
recall having seen that (though now I see ProcSleep also does it). It's
clearly all working as intended, but I think we could document it a bit
better.

> One side-effect of this is that this no longer calls disable_all_timeouts().
> Another minor issue related to that is being discussed at https://www.postgresql.org/message-id/CAHGQGwFJixYTymPZ6dwOO-G0VdjO1AgZTma6CtJgc0Ptxfz3BA@mail.gmail.com.
> We should fix that separately, this isn't enough to fix that issue, nor does
> it make it worse, but I thought I'd mention it.

Heh, that patch series seems to have started by touching the same code,
but ended up doing something completely different.

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
Thou shalt check the array bounds of all strings (indeed, all arrays), for
surely where thou typest "foo" someone someday shall type
"supercalifragilisticexpialidocious" (5th Commandment for C programmers)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-11-27 20:44:07 Re: Interrupts vs signals
Previous Message surya poondla 2026-11-27 20:41:14 Re: [BUG] pg_rewind: file sync bypass and findLastCheckpoint boundary crash