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

From Andrey Borodin
Subject Re: why pg_walfile_name() cannot be executed during recovery?
Date
Msg-id A7002722-492F-44F9-9AEE-DA031C443307@yandex-team.ru
Whole thread Raw
In response to Re: why pg_walfile_name() cannot be executed during recovery?  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Responses Re: why pg_walfile_name() cannot be executed during recovery?  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers

> On 9 Apr 2022, at 18:30, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> wrote:
>
> Using insert tli when not in recovery and using tli of the last WAL
> replayed record in crash/archive/standby recovery, seems a reasonable
> choice to me.

Please excuse me if I'm not attentive enough. I've read this thread. And I could not find what is the problem that you
aresolving. What is the purpose of the WAL file name you want to obtain? 

pg_walfile_name() - is a formatting function. With TLI as an hidden argument. If we want it to work on Standby we
shouldjust convert it to pure formatting function without access the the DB state, pass TLI as an argument. 
Making implicit TLI computation with certain expectations is not a good idea IMV.

pg_walfile_name() could just read .history file, determine which TLI contains given LSN and format the name. And still
there'sa tricky segments during TLI switch. 

Either way we can rename the function to pg_walfile_name_as_if_on_timeline_of_last_wal_replayed().

Thanks!

Best regards, Andrey Borodin.


pgsql-hackers by date:

Previous
From: "Jonathan S. Katz"
Date:
Subject: Re: How about a psql backslash command to show GUCs?
Next
From: Tom Lane
Date:
Subject: Re: How about a psql backslash command to show GUCs?