Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9a30e15

Browse files
committed
Use macros from xlog_internal.h for WAL segment logic in pg_resetwal
When scanning for the end of WAL, pg_resetwal has been maintaining itsown internal logic to calculate segment numbers and to parse a WALsegment name for its timeline and segment number. The code claimed forexample that XLogFromFileName() cannot be used because it lacks thepossibility of specifying a WAL segment size, which is not the casesincefc49e24, that has made the WAL segment size configurable atinitialization time, extending this routine to do so.Similarly, this switches one segment number calculation to useXLByteToSeg() rather than the same logic present in xlog_internal.h.While on it, switch to TimeLineID in pg_resetwal.c for TLI numbersparsed from segment names, to be more consistent withXLogFromFileName(). The maths are exactly the same, but the code getssimplified.Author: Bharath RupireddyReviewed-by: Kyotaro HoriguchiDiscussion:https://postgr.es/m/CALj2ACX+E_jnwqH_jmjhNG8BczJTNRTOLpw8K1CB1OcB48MJ8w@mail.gmail.com
1 parent9aa58d4 commit9a30e15

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

‎src/bin/pg_resetwal/pg_resetwal.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static TransactionId set_newest_commit_ts_xid = 0;
7171
staticOidset_oid=0;
7272
staticMultiXactIdset_mxid=0;
7373
staticMultiXactOffsetset_mxoff= (MultiXactOffset)-1;
74-
staticuint32minXlogTli=0;
74+
staticTimeLineIDminXlogTli=0;
7575
staticXLogSegNominXlogSegNo=0;
7676
staticintWalSegSz;
7777
staticintset_wal_segsize;
@@ -901,16 +901,15 @@ FindEndOfXLOG(void)
901901
{
902902
DIR*xldir;
903903
structdirent*xlde;
904-
uint64segs_per_xlogid;
905904
uint64xlogbytepos;
906905

907906
/*
908907
* Initialize the max() computation using the last checkpoint address from
909908
* old pg_control. Note that for the moment we are working with segment
910909
* numbering according to the old xlog seg size.
911910
*/
912-
segs_per_xlogid= (UINT64CONST(0x0000000100000000) /ControlFile.xlog_seg_size);
913-
newXlogSegNo=ControlFile.checkPointCopy.redo /ControlFile.xlog_seg_size;
911+
XLByteToSeg(ControlFile.checkPointCopy.redo,newXlogSegNo,
912+
ControlFile.xlog_seg_size);
914913

915914
/*
916915
* Scan the pg_wal directory to find existing WAL segment files. We assume
@@ -926,18 +925,12 @@ FindEndOfXLOG(void)
926925
if (IsXLogFileName(xlde->d_name)||
927926
IsPartialXLogFileName(xlde->d_name))
928927
{
929-
unsignedinttli,
930-
log,
931-
seg;
928+
TimeLineIDtli;
932929
XLogSegNosegno;
933930

934-
/*
935-
* Note: We don't use XLogFromFileName here, because we want to
936-
* use the segment size from the control file, not the size the
937-
* pg_resetwal binary was compiled with
938-
*/
939-
sscanf(xlde->d_name,"%08X%08X%08X",&tli,&log,&seg);
940-
segno= ((uint64)log)*segs_per_xlogid+seg;
931+
/* Use the segment size from the control file */
932+
XLogFromFileName(xlde->d_name,&tli,&segno,
933+
ControlFile.xlog_seg_size);
941934

942935
/*
943936
* Note: we take the max of all files found, regardless of their

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp