Re: binary version of pg_current_wal_insert_lsn and pg_walfile_name functions - Mailing list pgsql-hackers
From | Ashutosh Sharma |
---|---|
Subject | Re: binary version of pg_current_wal_insert_lsn and pg_walfile_name functions |
Date | |
Msg-id | CAE9k0PmCuTJ8GDyre80d_8=AtLy-9DaP01XHMUcfggnj18NZvg@mail.gmail.com Whole thread Raw |
In response to | Re: binary version of pg_current_wal_insert_lsn and pg_walfile_name functions (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>) |
Responses |
Re: binary version of pg_current_wal_insert_lsn and pg_walfile_name functions
|
List | pgsql-hackers |
On Fri, Sep 23, 2022 at 6:05 AM Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> wrote: > > On Thu, Sep 22, 2022 at 10:25 PM Ashutosh Sharma <ashu.coek88@gmail.com> wrote: > > > > PFA that enhances pg_waldump to show the latest LSN and the > > corresponding WAL file when the -l or --lastLSN option is passed an > > argument to pg_waldump. Below is an example: > > Thanks for the patch. I have some quick thoughts about it. > > > When the user passes the '-l' command line option along with the data > > directory path to pg_waldump, it reads the control file from the data > > directory. > > I don't think we need a new option for data directory -D. pg_waldump's > option 'p' can be used, please see the comments around > identify_target_directory(). > -p is the path to the WAL directory. It doesn't necessarily have to be a data directory, however the user can specify the data directory path here as well using which the path to the WAL directory can be recognized, but as I said it doesn't mean -p will always represent the data directory. > > From the control file, it gets information like redo > > pointer and current timeline id. > > Is there any reason for not using get_control_file() from > src/common/controldata_utils.c, but defining the exact same function > in pg_waldump.c? > Will give it a thought on it later. If possible, will try to reuse it. > > The redo pointer is considered to be > > the start pointer from where the pg_waldump starts reading wal data > > until end-of-wal to find the last LSN. For details please check the > > attached patch. > > Making it dependent on the controlfile limits the usability of this > feature. Imagine, using this feature on an archive location or > pg_receivewal target directory where there are WAL files but no > controlfile. I think we can choose the appropriate combinations of > existing pg_waldump options, for instance, let users enter the start > WAL segment via startseg and/or start LSN via --start and the new > option for end WAL segment and end LSN. > I have written this patch assuming that the end user is not aware of any LSN or any other WAL data and wants to know the last LSN. So all he can do is take the help of the control data to find the redo LSN and use that as a reference point (start pointer) to find the last LSN. And whatever is the WAL directory (be it archive location or wall collected via pg_receivewal or pg_wal directory), we will consider the redo pointer as the start pointer. Now, it's possible that the WAL corresponding to the start pointer is not at all available in the WAL directory like archive location or pg_receivewal directory in which this cannot be used, but this is very unlikely. > > Please note that for compressed and .partial wal files this doesn't work. > > Looking forward to the above capability because it expands the > usability of this feature. > This is a different task altogether. We will probably need to work on it separately. -- With Regards, Ashutosh Sharma.
pgsql-hackers by date: