Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2583480

Browse files
michaelpqpull[bot]
authored andcommitted
Remove emode argument from XLogFileRead() and XLogFileReadAnyTLI()
This change makes the code slightly easier to reason about, because there is actually no need to know if a specific caller of one of these routines should fail hard on a PANIC, or just let it go through with a DEBUG2. The only caller of XLogFileReadAnyTLI() used DEBUG2, and XLogFileRead() has never used its emode. This can be simplified since 1bb2558 that has introduced XLogFileReadAnyTLI(), splitting both. Author: Yugo Nagata Discussion: https://postgr.es/m/[email protected]
1 parent 129f305 commit 2583480

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/backend/access/transam/xlogrecovery.c

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,9 @@ static int emode_for_corrupt_record(int emode, XLogRecPtr RecPtr);
430430
static XLogRecord *ReadCheckpointRecord(XLogPrefetcher *xlogprefetcher,
431431
XLogRecPtr RecPtr, TimeLineID replayTLI);
432432
static bool rescanLatestTimeLine(TimeLineID replayTLI, XLogRecPtr replayLSN);
433-
static int XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
433+
static int XLogFileRead(XLogSegNo segno, TimeLineID tli,
434434
XLogSource source, bool notfoundOk);
435-
static int XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source);
435+
static int XLogFileReadAnyTLI(XLogSegNo segno, XLogSource source);
436436

437437
static bool CheckForStandbyTrigger(void);
438438
static void SetPromoteIsTriggered(void);
@@ -3780,7 +3780,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
37803780
* Try to restore the file from archive, or read an existing
37813781
* file from pg_wal.
37823782
*/
3783-
readFile = XLogFileReadAnyTLI(readSegNo, DEBUG2,
3783+
readFile = XLogFileReadAnyTLI(readSegNo,
37843784
currentSource == XLOG_FROM_ARCHIVE ? XLOG_FROM_ANY :
37853785
currentSource);
37863786
if (readFile >= 0)
@@ -3929,8 +3929,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
39293929
{
39303930
if (!expectedTLEs)
39313931
expectedTLEs = readTimeLineHistory(recoveryTargetTLI);
3932-
readFile = XLogFileRead(readSegNo, PANIC,
3933-
receiveTLI,
3932+
readFile = XLogFileRead(readSegNo, receiveTLI,
39343933
XLOG_FROM_STREAM, false);
39353934
Assert(readFile >= 0);
39363935
}
@@ -4201,7 +4200,7 @@ rescanLatestTimeLine(TimeLineID replayTLI, XLogRecPtr replayLSN)
42014200
* Otherwise, it's assumed to be already available in pg_wal.
42024201
*/
42034202
static int
4204-
XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
4203+
XLogFileRead(XLogSegNo segno, TimeLineID tli,
42054204
XLogSource source, bool notfoundOk)
42064205
{
42074206
char xlogfname[MAXFNAMELEN];
@@ -4283,7 +4282,7 @@ XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
42834282
* This version searches for the segment with any TLI listed in expectedTLEs.
42844283
*/
42854284
static int
4286-
XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source)
4285+
XLogFileReadAnyTLI(XLogSegNo segno, XLogSource source)
42874286
{
42884287
char path[MAXPGPATH];
42894288
ListCell *cell;
@@ -4347,8 +4346,7 @@ XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source)
43474346

43484347
if (source == XLOG_FROM_ANY || source == XLOG_FROM_ARCHIVE)
43494348
{
4350-
fd = XLogFileRead(segno, emode, tli,
4351-
XLOG_FROM_ARCHIVE, true);
4349+
fd = XLogFileRead(segno, tli, XLOG_FROM_ARCHIVE, true);
43524350
if (fd != -1)
43534351
{
43544352
elog(DEBUG1, "got WAL segment from archive");
@@ -4360,8 +4358,7 @@ XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source)
43604358

43614359
if (source == XLOG_FROM_ANY || source == XLOG_FROM_PG_WAL)
43624360
{
4363-
fd = XLogFileRead(segno, emode, tli,
4364-
XLOG_FROM_PG_WAL, true);
4361+
fd = XLogFileRead(segno, tli, XLOG_FROM_PG_WAL, true);
43654362
if (fd != -1)
43664363
{
43674364
if (!expectedTLEs)
@@ -4374,7 +4371,7 @@ XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source)
43744371
/* Couldn't find it. For simplicity, complain about front timeline */
43754372
XLogFilePath(path, recoveryTargetTLI, segno, wal_segment_size);
43764373
errno = ENOENT;
4377-
ereport(emode,
4374+
ereport(DEBUG2,
43784375
(errcode_for_file_access(),
43794376
errmsg("could not open file \"%s\": %m", path)));
43804377
return -1;

0 commit comments

Comments
 (0)