From bf312ecb9da7201fc76d11c820c6b18e680d9842 Mon Sep 17 00:00:00 2001 From: wuyuechuan Date: Wed, 29 Nov 2023 17:27:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=A7=BB=E9=99=A4recovery=5Ftarget=5Ftime?= =?UTF-8?q?=E6=80=BB=E6=98=AF=E4=B8=BAbackup=5Fend=E7=9A=84=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E3=80=82=E5=AF=B9=E4=BA=8E=E6=89=80=E6=9C=89=E7=9A=84?= =?UTF-8?q?PITR=E6=81=A2=E5=A4=8D=E5=9C=BA=E6=99=AF=EF=BC=8C=E9=99=A4?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=8C=87=E5=AE=9Arecovery=5Fcommand=E5=A4=96?= =?UTF-8?q?=EF=BC=8C=E5=85=A8=E9=83=A8=E9=80=9A=E8=BF=87warning=E6=8F=90?= =?UTF-8?q?=E9=86=92=E5=AE=A2=E6=88=B7=EF=BC=8C=E9=9C=80=E8=A6=81=E8=87=AA?= =?UTF-8?q?=E8=A1=8C=E8=BE=93=E5=85=A5restore=20command=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bin/pg_probackup/restore.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/bin/pg_probackup/restore.cpp b/src/bin/pg_probackup/restore.cpp index 4e24b55d5..3e57530ec 100644 --- a/src/bin/pg_probackup/restore.cpp +++ b/src/bin/pg_probackup/restore.cpp @@ -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."); + } } From 0f1fdf0879c89f1ebc1fb58e9e8d50914c1d513b Mon Sep 17 00:00:00 2001 From: wuyuechuan Date: Mon, 4 Dec 2023 15:41:51 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=A7=BB=E9=99=A4pg=5Fstart=5Fbackup?= =?UTF-8?q?=E7=9A=84endRequired=E3=80=82=E4=BF=AE=E6=94=B9=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E6=98=AF=E5=90=A6=E6=B8=85=E7=A9=BAstartpoint?= =?UTF-8?q?=E5=92=8Cendpoint=E9=80=BB=E8=BE=91=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/storage/access/transam/xlog.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gausskernel/storage/access/transam/xlog.cpp b/src/gausskernel/storage/access/transam/xlog.cpp index 800cef6fb..e3af6b5a7 100755 --- a/src/gausskernel/storage/access/transam/xlog.cpp +++ b/src/gausskernel/storage/access/transam/xlog.cpp @@ -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; } }