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 1bb2558046cc that has introduced XLogFileReadAnyTLI(), splitting both. Author: Yugo Nagata Discussion: https://postgr.es/m/20240906201043.a640f3b44e755d4db2b6943e@sraoss.co.jp
This commit is contained in:
parent
bb77752342
commit
fba49d5293
@ -430,9 +430,9 @@ static int emode_for_corrupt_record(int emode, XLogRecPtr RecPtr);
|
||||
static XLogRecord *ReadCheckpointRecord(XLogPrefetcher *xlogprefetcher,
|
||||
XLogRecPtr RecPtr, TimeLineID replayTLI);
|
||||
static bool rescanLatestTimeLine(TimeLineID replayTLI, XLogRecPtr replayLSN);
|
||||
static int XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
|
||||
static int XLogFileRead(XLogSegNo segno, TimeLineID tli,
|
||||
XLogSource source, bool notfoundOk);
|
||||
static int XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source);
|
||||
static int XLogFileReadAnyTLI(XLogSegNo segno, XLogSource source);
|
||||
|
||||
static bool CheckForStandbyTrigger(void);
|
||||
static void SetPromoteIsTriggered(void);
|
||||
@ -3780,7 +3780,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
|
||||
* Try to restore the file from archive, or read an existing
|
||||
* file from pg_wal.
|
||||
*/
|
||||
readFile = XLogFileReadAnyTLI(readSegNo, DEBUG2,
|
||||
readFile = XLogFileReadAnyTLI(readSegNo,
|
||||
currentSource == XLOG_FROM_ARCHIVE ? XLOG_FROM_ANY :
|
||||
currentSource);
|
||||
if (readFile >= 0)
|
||||
@ -3929,8 +3929,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
|
||||
{
|
||||
if (!expectedTLEs)
|
||||
expectedTLEs = readTimeLineHistory(recoveryTargetTLI);
|
||||
readFile = XLogFileRead(readSegNo, PANIC,
|
||||
receiveTLI,
|
||||
readFile = XLogFileRead(readSegNo, receiveTLI,
|
||||
XLOG_FROM_STREAM, false);
|
||||
Assert(readFile >= 0);
|
||||
}
|
||||
@ -4201,7 +4200,7 @@ rescanLatestTimeLine(TimeLineID replayTLI, XLogRecPtr replayLSN)
|
||||
* Otherwise, it's assumed to be already available in pg_wal.
|
||||
*/
|
||||
static int
|
||||
XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
|
||||
XLogFileRead(XLogSegNo segno, TimeLineID tli,
|
||||
XLogSource source, bool notfoundOk)
|
||||
{
|
||||
char xlogfname[MAXFNAMELEN];
|
||||
@ -4283,7 +4282,7 @@ XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
|
||||
* This version searches for the segment with any TLI listed in expectedTLEs.
|
||||
*/
|
||||
static int
|
||||
XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source)
|
||||
XLogFileReadAnyTLI(XLogSegNo segno, XLogSource source)
|
||||
{
|
||||
char path[MAXPGPATH];
|
||||
ListCell *cell;
|
||||
@ -4347,8 +4346,7 @@ XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source)
|
||||
|
||||
if (source == XLOG_FROM_ANY || source == XLOG_FROM_ARCHIVE)
|
||||
{
|
||||
fd = XLogFileRead(segno, emode, tli,
|
||||
XLOG_FROM_ARCHIVE, true);
|
||||
fd = XLogFileRead(segno, tli, XLOG_FROM_ARCHIVE, true);
|
||||
if (fd != -1)
|
||||
{
|
||||
elog(DEBUG1, "got WAL segment from archive");
|
||||
@ -4360,8 +4358,7 @@ XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source)
|
||||
|
||||
if (source == XLOG_FROM_ANY || source == XLOG_FROM_PG_WAL)
|
||||
{
|
||||
fd = XLogFileRead(segno, emode, tli,
|
||||
XLOG_FROM_PG_WAL, true);
|
||||
fd = XLogFileRead(segno, tli, XLOG_FROM_PG_WAL, true);
|
||||
if (fd != -1)
|
||||
{
|
||||
if (!expectedTLEs)
|
||||
@ -4374,7 +4371,7 @@ XLogFileReadAnyTLI(XLogSegNo segno, int emode, XLogSource source)
|
||||
/* Couldn't find it. For simplicity, complain about front timeline */
|
||||
XLogFilePath(path, recoveryTargetTLI, segno, wal_segment_size);
|
||||
errno = ENOENT;
|
||||
ereport(emode,
|
||||
ereport(DEBUG2,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not open file \"%s\": %m", path)));
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user