Re: why pg_walfile_name() cannot be executed during recovery? - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: why pg_walfile_name() cannot be executed during recovery?
Date
Msg-id Yk9643e5LpQ/FlBW@paquier.xyz
Whole thread Raw
In response to Re: why pg_walfile_name() cannot be executed during recovery?  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On Thu, Apr 07, 2022 at 11:37:15AM -0400, Robert Haas wrote:
> It's also worth noting that there's a bit of a definitional problem
> here. If in the same situation, I ask for pg_walfile_name('11/0'),
> it's going to give me a filename based on TLI 2, but there's also a
> WAL file for that LSN with TLI 1. How do we know which one the user
> wants? Perhaps one idea would be to say that the relevant TLI is the
> one which was in effect at the time that LSN was replayed. If we do
> that, what about future LSNs? We could assume that for future LSNs,
> the TLI should be the same as the current TLI, but maybe that's also
> misleading, because recovery_target_timeline could be set.

FWIW, for future positions, I'd be rather on board with the concept of
using the TLI currently being replayed, but as you say that comes down
to the definition borders we want to use.  Another possibility would
be to return an error and kick the can down the road if we are unsure
of what the right behavior is.  For past positions, this should go
through a lookup of the timeline history file (the patch does not do
that at quick glance).

> I think it's really important to start by being precise about the
> question that we think pg_walfile_name() ought to be answering. If we
> don't know that, then we really can't say what TLI it should be using.
> It's not hard to make the function return SOME answer using SOME TLI,
> but then it's not clear that the answer is the right one for any
> particular purpose. And in that case the function is more dangerous
> than useful, because people will write code that uses it to do stuff,
> and then that stuff won't actually work correctly under all
> circumstances.

Agreed.
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Can we automatically add elapsed times to tap test log?
Next
From: Justin Pryzby
Date:
Subject: Re: logical decoding and replication of sequences