On Thu, Sep 22, 2022 at 7:41 AM Bharath Rupireddy <bharath.rupireddyforpostg...@gmail.com> wrote: > > On Wed, Sep 21, 2022 at 9:53 PM Ashutosh Sharma <ashu.coe...@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.
0001-Enhance-pg_waldump-to-show-latest-LSN-and-the-WAL-fi.patch
Description: Binary data