Re: Use XLogFromFileName() in pg_resetwal to parse position from WAL file - Mailing list pgsql-hackers

From Kyotaro Horiguchi
Subject Re: Use XLogFromFileName() in pg_resetwal to parse position from WAL file
Date
Msg-id 20221004.151706.1776810688016105797.horikyota.ntt@gmail.com
Whole thread Raw
In response to Use XLogFromFileName() in pg_resetwal to parse position from WAL file  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Responses Re: Use XLogFromFileName() in pg_resetwal to parse position from WAL file  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Re: Use XLogFromFileName() in pg_resetwal to parse position from WAL file  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Re: Use XLogFromFileName() in pg_resetwal to parse position from WAL file  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
At Tue, 4 Oct 2022 11:06:15 +0530, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com> wrote in 
> It looks like there's an opportunity to replace explicit WAL file
> parsing code with XLogFromFileName() in pg_resetwal.c. This was not
> done then (in PG 10) because the XLogFromFileName() wasn't accepting
> file size as an input parameter (see [1]) and pg_resetwal needed to
> use WAL file size from the controlfile. Thanks to the commit
> fc49e24fa69a15efacd5b8958115ed9c43c48f9a which added the
> wal_segsz_bytes parameter to XLogFromFileName().

Nice finding. I found a few '%08X%08X's but they don't seem to fit
similar fix.

> I'm attaching a small patch herewith. This removes using extra
> variables in pg_resetwal.c and a bit of duplicate code too (5 LOC).
> 
> Thoughts?

> -    segs_per_xlogid = (UINT64CONST(0x0000000100000000) / ControlFile.xlog_seg_size);
>      newXlogSegNo = ControlFile.checkPointCopy.redo / ControlFile.xlog_seg_size;

Couldn't we use XLByteToSeg() here?

Other than that, it looks good to me.

> [1] https://github.com/postgres/postgres/blob/REL_10_STABLE/src/include/access/xlog_internal.h

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



pgsql-hackers by date:

Previous
From: Никита Старовойтов
Date:
Subject: possibility of partial data dumps with pg_dump
Next
From: Bharath Rupireddy
Date:
Subject: Re: Use XLogFromFileName() in pg_resetwal to parse position from WAL file