!4520 移除recovery_target_time总是为backup_end的场景。对于所有的PITR恢复场景,除用户指定restore_command外,其他场景都做好相关的command提示

Merge pull request !4520 from 吴岳川/probackup
This commit is contained in:
opengauss_bot
2023-12-05 09:16:10 +00:00
committed by Gitee
2 changed files with 14 additions and 18 deletions

View File

@ -1660,17 +1660,7 @@ create_recovery_conf(time_t backup_id,
/* construct restore_command */
if (pitr_requested)
{
char *timestamp = NULL;
const char *oldtime = NULL;
timestamp = (char *)pg_malloc(RESTORE_ARRAY_LEN);
time2iso(timestamp, RESTORE_ARRAY_LEN, backup->end_time);
oldtime = rt->time_string;
if (rt->time_string) {
rt->time_string = timestamp;
}
construct_restore_cmd(fp, rt, restore_command_provided, target_immediate);
rt->time_string = oldtime;
free(timestamp);
}
if (fio_fflush(fp) != 0 ||
@ -1752,10 +1742,17 @@ static void construct_restore_cmd(FILE *fp, pgRecoveryTarget *rt,
fio_fprintf(fp, "recovery_target_timeline = 'current'\n");
#endif
}
if (instance_config.archive.host) {
elog(LOG, "archive host specified, input restore command manually.");
if (restore_command_provided)
{
char restore_command_guc[16384];
errno_t rc = sprintf_s(restore_command_guc, sizeof(restore_command_guc), "%s", instance_config.restore_command);
securec_check_ss_c(rc, "\0", "\0");
fio_fprintf(fp, "restore_command = '%s\n", restore_command_guc);
elog(LOG, "Setting restore command to '%s'", restore_command_guc);
} else {
fprintf(fp, "restore_command = 'cp %s/%%f %%p'\n", arclog_path);
elog(WARNING, "you need to input restore command manually.");
}
}

View File

@ -11319,9 +11319,11 @@ void CheckRecoveryConsistency(void)
return;
/*
* Have we reached the point where our base backup was completed?
* backupStartPoint may clear when XLOG_BACKUP_END redo
*/
if (!XLogRecPtrIsInvalid(t_thrd.shemem_ptr_cxt.ControlFile->backupEndPoint) &&
!XLogRecPtrIsInvalid(t_thrd.shemem_ptr_cxt.ControlFile->backupStartPoint) &&
(!t_thrd.shemem_ptr_cxt.ControlFile->backupEndRequired ||
!XLogRecPtrIsInvalid(t_thrd.shemem_ptr_cxt.ControlFile->backupStartPoint)) &&
XLByteLE(t_thrd.shemem_ptr_cxt.ControlFile->backupEndPoint, lastReplayedEndRecPtr)) {
/*
* We have reached the end of base backup, as indicated by pg_control.
@ -14148,8 +14150,7 @@ void xlog_redo(XLogReaderState *record)
rc = memcpy_s(&startpoint, sizeof(startpoint), XLogRecGetData(record), sizeof(startpoint));
securec_check(rc, "", "");
if (XLByteEQ(t_thrd.shemem_ptr_cxt.ControlFile->backupStartPoint, startpoint) &&
t_thrd.shemem_ptr_cxt.ControlFile->backupEndRequired) {
if (XLByteEQ(t_thrd.shemem_ptr_cxt.ControlFile->backupStartPoint, startpoint)) {
/*
* We have reached the end of base backup, the point where
* pg_stop_backup() was done. The data on disk is now consistent.
@ -16740,8 +16741,6 @@ static bool read_backup_label(XLogRecPtr *checkPointLoc, bool *backupEndRequired
if (fscanf_s(lfp, "BACKUP METHOD: %19s\n", backuptype, sizeof(backuptype)) == 1) {
if (strcmp(backuptype, "streamed") == 0) {
*backupEndRequired = true;
} else if (strcmp(backuptype, "pg_start_backup") == 0) {
*backupEndRequired = true;
}
}