forked from huawei/openGauss-server
解决归档流程会因为备机不存在对应的xlog文件而卡住的bug
This commit is contained in:
parent
87139aeb02
commit
3290af6a23
|
|
@ -1018,18 +1018,29 @@ static void pgarch_archiveDone(const char* xlog)
|
|||
*/
|
||||
static void pgarch_archiveRoachForPitrStandby()
|
||||
{
|
||||
XLogRecPtr targetLsn = g_instance.archive_obs_cxt.archive_task.targetLsn;
|
||||
if (!XlogFileIsExisted(t_thrd.proc_cxt.DataDir, targetLsn, DEFAULT_TIMELINE_ID)) {
|
||||
g_instance.archive_obs_cxt.pitr_result_type = ARCH_SKIP;
|
||||
g_instance.archive_obs_cxt.pitr_finish_result = true;
|
||||
ereport(WARNING,
|
||||
(errmsg("pgarch_archiveRoachForPitrStandby %X/%X is not exists, skip the process of archiving",
|
||||
(uint32)(targetLsn >> 32), (uint32)(targetLsn))));
|
||||
return;
|
||||
}
|
||||
ereport(LOG,
|
||||
(errmsg("pgarch_archiveRoachForPitrStandby %X/%X, term:%d, subterm:%d",
|
||||
(uint32)(g_instance.archive_obs_cxt.archive_task.targetLsn >> 32), (uint32)(g_instance.archive_obs_cxt.archive_task.targetLsn),
|
||||
(uint32)(targetLsn >> 32), (uint32)(targetLsn),
|
||||
g_instance.archive_obs_cxt.archive_task.term, g_instance.archive_obs_cxt.archive_task.sub_term)));
|
||||
if (obs_replication_archive(&g_instance.archive_obs_cxt.archive_task) == 0) {
|
||||
g_instance.archive_obs_cxt.pitr_finish_result = true;
|
||||
g_instance.archive_obs_cxt.pitr_result_type = ARCH_SUCCESS;
|
||||
} else {
|
||||
ereport(WARNING,
|
||||
(errmsg("error when pgarch_archiveRoachForPitrStandby %X/%X, term:%d, subterm:%d",
|
||||
(uint32)(g_instance.archive_obs_cxt.archive_task.targetLsn >> 32), (uint32)(g_instance.archive_obs_cxt.archive_task.targetLsn),
|
||||
(uint32)(targetLsn >> 32), (uint32)(targetLsn),
|
||||
g_instance.archive_obs_cxt.archive_task.term, g_instance.archive_obs_cxt.archive_task.sub_term)));
|
||||
g_instance.archive_obs_cxt.pitr_finish_result = false;
|
||||
g_instance.archive_obs_cxt.pitr_result_type = ARCH_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1919,7 +1919,7 @@ static void WalRecvSendArchiveXlogResponse()
|
|||
errno_t errorno = EOK;
|
||||
reply.pitr_result = g_instance.archive_obs_cxt.pitr_finish_result;
|
||||
reply.targetLsn = g_instance.archive_obs_cxt.archive_task.targetLsn;
|
||||
|
||||
reply.result_type = g_instance.archive_obs_cxt.pitr_result_type;
|
||||
buf[0] = 'a';
|
||||
errorno = memcpy_s(&buf[1],
|
||||
sizeof(ArchiveXlogResponseMeeeage),
|
||||
|
|
|
|||
|
|
@ -2538,9 +2538,16 @@ static void ProcessArchiveFeedbackMessage(void)
|
|||
ArchiveXlogResponseMeeeage reply;
|
||||
/* Decipher the reply message */
|
||||
pq_copymsgbytes(t_thrd.walsender_cxt.reply_message, (char*)&reply, sizeof(ArchiveXlogResponseMeeeage));
|
||||
ereport(LOG,
|
||||
(errmsg("ProcessArchiveFeedbackMessage %d %X/%X", reply.pitr_result,
|
||||
(uint32)(reply.targetLsn >> 32), (uint32)(reply.targetLsn))));
|
||||
if (reply.pitr_result && reply.result_type == ARCH_SKIP) {
|
||||
ereport(WARNING,
|
||||
(errmsg("ProcessArchiveFeedbackMessage %X/%X is not exists in the standby, skip it",
|
||||
(uint32)(reply.targetLsn >> 32), (uint32)(reply.targetLsn))));
|
||||
} else {
|
||||
ereport(LOG,
|
||||
(errmsg("ProcessArchiveFeedbackMessage %d %X/%X", reply.pitr_result,
|
||||
(uint32)(reply.targetLsn >> 32), (uint32)(reply.targetLsn))));
|
||||
}
|
||||
|
||||
g_instance.archive_obs_cxt.pitr_finish_result = reply.pitr_result;
|
||||
g_instance.archive_obs_cxt.archive_task.targetLsn = reply.targetLsn;
|
||||
if (walsnd->arch_latch == NULL) {
|
||||
|
|
|
|||
|
|
@ -740,6 +740,14 @@ typedef struct knl_g_archive_obs_context {
|
|||
volatile int sync_walsender_idx;
|
||||
volatile long last_arch_time;
|
||||
volatile XLogRecPtr pitr_task_last_lsn;
|
||||
|
||||
/*
|
||||
* walreceiver set the archiving result type
|
||||
* 0 for archiving failed
|
||||
* 1 for archiving success
|
||||
* 2 is skipping the archiving becasuse of the xlog does not exists
|
||||
*/
|
||||
volatile unsigned int pitr_result_type;
|
||||
} knl_g_archive_obs_context;
|
||||
|
||||
#ifdef ENABLE_MOT
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ typedef struct ArchiveXlogMessage {
|
|||
typedef struct ArchiveXlogResponseMeeeage {
|
||||
bool pitr_result;
|
||||
XLogRecPtr targetLsn;
|
||||
uint32 result_type;
|
||||
} ArchiveXlogResponseMeeeage;
|
||||
|
||||
/*
|
||||
|
|
@ -173,6 +174,12 @@ typedef enum {
|
|||
PITR_TASK_DONE
|
||||
} PITR_TASK_STATUS;
|
||||
|
||||
typedef enum {
|
||||
ARCH_FAILED = 0,
|
||||
ARCH_SUCCESS,
|
||||
ARCH_SKIP
|
||||
} PITR_RESULT_TYPE;
|
||||
|
||||
/*
|
||||
* switchover response message from primary (message type 'p'). This is wrapped within
|
||||
* a CopyData message at the FE/BE protocol level.
|
||||
|
|
|
|||
Loading…
Reference in New Issue