Re: improving handling of FPIs during recovery prefetching

From: Tomas Vondra <tomas(at)vondra(dot)me>
To: Jan Nidzwetzki <jan(at)planetscale(dot)com>, shihao zhong <zhong950419(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Jeremy Schneider <schneider(at)ardentperf(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Subject: Re: improving handling of FPIs during recovery prefetching
Date: 2026-11-10 12:20:08
Message-ID: 60a1221b-125b-481c-b019-66366a9e2673@vondra.me
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/10/26 13:10, Jan Nidzwetzki wrote:
> Hi Shihao,
>
> ...
>
> In 042_low_level_backup.pl, a similar operation is performed, but the
> WAL file name is directly taken from the LSN returned by
> pg_switch_wal(). What do you think about changing the code in the same
> way? With the change below, the test passes even with the injected
> pg_log_standby_snapshot() line.
>
> ---
> my $end_lsn = $primary->safe_psql('postgres', 'SELECT pg_switch_wal()');
> my $walfile = $primary->safe_psql('postgres',
> "SELECT pg_walfile_name('$end_lsn')");
> ---
>
> Apart from this, the test looks good to me.
>

Thanks for looking at the patch and for the TAP test.

FYI I had a chat with Thomas Munro, who wrote the current recovery
prefetcher, and he has some ideas for an alternative (simpler, better)
way to make it skip FPIs. I don't have an ETA for his version, but an
optimist me expects it to be posted soon-ish. So maybe let's not waste
too much time reviewing this patch yet, we can revive it if the better
version does not arrive.

That being said, I think it'll need some sort of TAP test too, so the
one posted here might be useful.

FWIW one aspect of my patch worth checking would be the cost for "normal
cases" where recovery works perfectly fine without the patch. The lookup
in the new "history" cache might be adding measurable CPU overhead, or
something like that. I don't think it does (and I haven't managed to
construct such case), but if someone else verified it, that'd be good.

regards

--
Tomas Vondra

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Jones 2026-11-10 12:29:20 XMLElement() and XMLForest() embed the XML declaration of xml arguments
Previous Message yangboyu 2026-11-10 12:18:30 Re:logical decoding: skip unnecessary snapshot distribution.