Re: binary version of pg_current_wal_insert_lsn and pg_walfile_name functions

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: binary version of pg_current_wal_insert_lsn and pg_walfile_name functions
Date: 2022-09-23 00:35:36
Message-ID: CALj2ACWG3FmvXvYLqC6vMj2poLAf0MxvLBoQ4iqoCc26za9a2w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 22, 2022 at 10:25 PM Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)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().

> 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?

> 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.

> 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.

--
Bharath Rupireddy
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2022-09-23 02:00:00 Re: libpq error message refactoring
Previous Message Bharath Rupireddy 2022-09-23 00:32:24 Re: Refactor backup related code (was: Is it correct to say, "invalid data in file \"%s\"", BACKUP_LABEL_FILE in do_pg_backup_stop?)