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 CAE9k0Pk_2_LvRPVRAT_U2nC=bu9fzQuxf=fwPDRugo6-DRz+gA@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 Thu, Sep 22, 2022 at 7:41 AM Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:
>
> On Wed, Sep 21, 2022 at 9:53 PM Ashutosh Sharma <ashu.coek88@gmail.com> wrote:
> >
> > Yeah, we can either add this functionality to pg_waldump or maybe add
> > a new binary itself that would return this information.
>
> IMV, a separate tool isn't the way, since pg_waldump already reads WAL
> files and decodes WAL records, what's proposed here can be an
> additional functionality of pg_waldump.
>
> It will be great if an initial patch is posted here.
>

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:

ashu@92893de650ed:~/pgsql$ pg_waldump -l -D ./data-dir
Latest LSN: 0/148A45F8
Latest WAL filename: 000000010000000000000014

How has it been coded?

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. From the control file, it gets information like redo
pointer and current timeline id. 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.

Please note that for compressed and .partial wal files this doesn't work.

--
With Regards,
Ashutosh Sharma.

Attachment

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Reducing the WAL overhead of freezing in VACUUM by deduplicating per-tuple freeze plans
Next
From: Andres Freund
Date:
Subject: Re: Extending outfuncs support to utility statements