Skip to content

Commit 2387f52

Browse files
committed
Remove useless arguments in ReadCheckpointRecord().
This commit removes two arguments "report" and "whichChkpt" in ReadCheckpointRecord(). "report" is obviously useless because it's always true, i.e., there are two callers of the function and they always specify true as "report". Commit 1d919de removed the only call with "report" = false. "whichChkpt" indicated where the specified checkpoint location came from, pg_control or backup_label. This information was used to report different error messages depending on where the invalid checkpoint record came from, when it was found. But ReadCheckpointRecord() doesn't need to do that because its callers already do that and users can still identify where the invalid checkpoint record came from, by reading such log messages. Also when "whichChkpt" was 0, the word "primary checkpoint" was used in the log message and could confuse users because the concept of primary and secondary checkpoints was already removed before. These are why this commit removes "whichChkpt" argument. Author: Fujii Masao Reviewed-by: Bharath Rupireddy, Kyotaro Horiguchi Discussion: https://postgr.es/m/fa2e12eb-81c3-0717-0272-755f8a81c8f2@oss.nttdata.com
1 parent 6955bba commit 2387f52

File tree

1 file changed

+15
-69
lines changed

1 file changed

+15
-69
lines changed

src/backend/access/transam/xlogrecovery.c

Lines changed: 15 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,8 @@ static XLogPageReadResult WaitForWALToBecomeAvailable(XLogRecPtr RecPtr,
422422
XLogRecPtr replayLSN,
423423
bool nonblocking);
424424
static int emode_for_corrupt_record(int emode, XLogRecPtr RecPtr);
425-
static XLogRecord *ReadCheckpointRecord(XLogPrefetcher *xlogprefetcher, XLogRecPtr RecPtr,
426-
int whichChkpt, bool report, TimeLineID replayTLI);
425+
static XLogRecord *ReadCheckpointRecord(XLogPrefetcher *xlogprefetcher,
426+
XLogRecPtr RecPtr, TimeLineID replayTLI);
427427
static bool rescanLatestTimeLine(TimeLineID replayTLI, XLogRecPtr replayLSN);
428428
static int XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
429429
XLogSource source, bool notfoundOk);
@@ -605,7 +605,7 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
605605
* When a backup_label file is present, we want to roll forward from
606606
* the checkpoint it identifies, rather than using pg_control.
607607
*/
608-
record = ReadCheckpointRecord(xlogprefetcher, CheckPointLoc, 0, true,
608+
record = ReadCheckpointRecord(xlogprefetcher, CheckPointLoc,
609609
CheckPointTLI);
610610
if (record != NULL)
611611
{
@@ -744,7 +744,7 @@ InitWalRecovery(ControlFileData *ControlFile, bool *wasShutdown_ptr,
744744
CheckPointTLI = ControlFile->checkPointCopy.ThisTimeLineID;
745745
RedoStartLSN = ControlFile->checkPointCopy.redo;
746746
RedoStartTLI = ControlFile->checkPointCopy.ThisTimeLineID;
747-
record = ReadCheckpointRecord(xlogprefetcher, CheckPointLoc, 1, true,
747+
record = ReadCheckpointRecord(xlogprefetcher, CheckPointLoc,
748748
CheckPointTLI);
749749
if (record != NULL)
750750
{
@@ -3843,13 +3843,10 @@ emode_for_corrupt_record(int emode, XLogRecPtr RecPtr)
38433843

38443844
/*
38453845
* Subroutine to try to fetch and validate a prior checkpoint record.
3846-
*
3847-
* whichChkpt identifies the checkpoint (merely for reporting purposes).
3848-
* 1 for "primary", 0 for "other" (backup_label)
38493846
*/
38503847
static XLogRecord *
38513848
ReadCheckpointRecord(XLogPrefetcher *xlogprefetcher, XLogRecPtr RecPtr,
3852-
int whichChkpt, bool report, TimeLineID replayTLI)
3849+
TimeLineID replayTLI)
38533850
{
38543851
XLogRecord *record;
38553852
uint8 info;
@@ -3858,20 +3855,8 @@ ReadCheckpointRecord(XLogPrefetcher *xlogprefetcher, XLogRecPtr RecPtr,
38583855

38593856
if (!XRecOffIsValid(RecPtr))
38603857
{
3861-
if (!report)
3862-
return NULL;
3863-
3864-
switch (whichChkpt)
3865-
{
3866-
case 1:
3867-
ereport(LOG,
3868-
(errmsg("invalid primary checkpoint link in control file")));
3869-
break;
3870-
default:
3871-
ereport(LOG,
3872-
(errmsg("invalid checkpoint link in backup_label file")));
3873-
break;
3874-
}
3858+
ereport(LOG,
3859+
(errmsg("invalid checkpoint location")));
38753860
return NULL;
38763861
}
38773862

@@ -3880,67 +3865,28 @@ ReadCheckpointRecord(XLogPrefetcher *xlogprefetcher, XLogRecPtr RecPtr,
38803865

38813866
if (record == NULL)
38823867
{
3883-
if (!report)
3884-
return NULL;
3885-
3886-
switch (whichChkpt)
3887-
{
3888-
case 1:
3889-
ereport(LOG,
3890-
(errmsg("invalid primary checkpoint record")));
3891-
break;
3892-
default:
3893-
ereport(LOG,
3894-
(errmsg("invalid checkpoint record")));
3895-
break;
3896-
}
3868+
ereport(LOG,
3869+
(errmsg("invalid checkpoint record")));
38973870
return NULL;
38983871
}
38993872
if (record->xl_rmid != RM_XLOG_ID)
39003873
{
3901-
switch (whichChkpt)
3902-
{
3903-
case 1:
3904-
ereport(LOG,
3905-
(errmsg("invalid resource manager ID in primary checkpoint record")));
3906-
break;
3907-
default:
3908-
ereport(LOG,
3909-
(errmsg("invalid resource manager ID in checkpoint record")));
3910-
break;
3911-
}
3874+
ereport(LOG,
3875+
(errmsg("invalid resource manager ID in checkpoint record")));
39123876
return NULL;
39133877
}
39143878
info = record->xl_info & ~XLR_INFO_MASK;
39153879
if (info != XLOG_CHECKPOINT_SHUTDOWN &&
39163880
info != XLOG_CHECKPOINT_ONLINE)
39173881
{
3918-
switch (whichChkpt)
3919-
{
3920-
case 1:
3921-
ereport(LOG,
3922-
(errmsg("invalid xl_info in primary checkpoint record")));
3923-
break;
3924-
default:
3925-
ereport(LOG,
3926-
(errmsg("invalid xl_info in checkpoint record")));
3927-
break;
3928-
}
3882+
ereport(LOG,
3883+
(errmsg("invalid xl_info in checkpoint record")));
39293884
return NULL;
39303885
}
39313886
if (record->xl_tot_len != SizeOfXLogRecord + SizeOfXLogRecordDataHeaderShort + sizeof(CheckPoint))
39323887
{
3933-
switch (whichChkpt)
3934-
{
3935-
case 1:
3936-
ereport(LOG,
3937-
(errmsg("invalid length of primary checkpoint record")));
3938-
break;
3939-
default:
3940-
ereport(LOG,
3941-
(errmsg("invalid length of checkpoint record")));
3942-
break;
3943-
}
3888+
ereport(LOG,
3889+
(errmsg("invalid length of checkpoint record")));
39443890
return NULL;
39453891
}
39463892
return record;

0 commit comments

Comments
 (0)