forked from huawei/openGauss-server
fix pitr force advance archive slot failed
Offering: openGaussDev More detail: Modify pgarch walsender and walreceiver Match-id-99d82487ad3d4e927779aa40996fb062fc7ea357
This commit is contained in:
parent
ea0a5061e9
commit
de631b5047
|
|
@ -748,6 +748,10 @@ static void pgarch_ArchiverObsCopyLoop(XLogRecPtr flushPtr, doArchive fun)
|
|||
(uint32)(targetLsn >> 32), (uint32)(targetLsn))));
|
||||
pg_usleep(1000000L); /* wait a bit before retrying */
|
||||
} else {
|
||||
if (g_instance.roach_cxt.isXLogForceRecycled && !g_instance.roach_cxt.forceAdvanceSlotTigger) {
|
||||
g_instance.roach_cxt.isXLogForceRecycled = false;
|
||||
ereport(LOG, (errmsg("PgArch force advance slot success")));
|
||||
}
|
||||
gettimeofday(&tv, NULL);
|
||||
currTimestamp = TIME_GET_MILLISEC(tv);
|
||||
t_thrd.arch.pitr_task_last_lsn = targetLsn;
|
||||
|
|
@ -1035,6 +1039,11 @@ static void pgarch_archiveRoachForPitrStandby()
|
|||
(uint32)(archive_task_status->archive_task.targetLsn),
|
||||
archive_task_status->archive_task.term,
|
||||
archive_task_status->archive_task.sub_term)));
|
||||
if (archive_task_status->archive_task.targetLsn == InvalidXLogSegPtr) {
|
||||
volatile unsigned int *pitr_task_status = &archive_task_status->pitr_task_status;
|
||||
pg_atomic_write_u32(pitr_task_status, PITR_TASK_NONE);
|
||||
ereport(LOG, (errmsg("PgArch standby receive invalid lsn for slot force advance")));
|
||||
}
|
||||
if (ArchiveReplicationAchiver(&archive_task_status->archive_task) == 0) {
|
||||
archive_task_status->pitr_finish_result = true;
|
||||
} else {
|
||||
|
|
@ -1066,6 +1075,11 @@ static bool pgarch_archiveRoachForPitrMaster(XLogRecPtr targetLsn)
|
|||
archive_task_status->archive_task.tli = get_controlfile_timeline();
|
||||
archive_task_status->archive_task.term = Max(g_instance.comm_cxt.localinfo_cxt.term_from_file,
|
||||
g_instance.comm_cxt.localinfo_cxt.term_from_xlog);
|
||||
if (g_instance.roach_cxt.forceAdvanceSlotTigger) {
|
||||
archive_task_status->archive_task.targetLsn = InvalidXLogRecPtr;
|
||||
g_instance.roach_cxt.forceAdvanceSlotTigger = false;
|
||||
ereport(LOG, (errmsg("PgArch need force advance this time in primary")));
|
||||
}
|
||||
/* subterm update when walsender changed */
|
||||
int rc = strcpy_s(archive_task_status->archive_task.slot_name, NAMEDATALEN, t_thrd.arch.slot_name);
|
||||
securec_check(rc, "\0", "\0");
|
||||
|
|
@ -1094,8 +1108,8 @@ static bool pgarch_archiveRoachForPitrMaster(XLogRecPtr targetLsn)
|
|||
return false;
|
||||
}
|
||||
/*
|
||||
* check targetLsn and g_instance.archive_obs_cxt.archive_task.targetLsn for deal message with wrong order
|
||||
*/
|
||||
* check targetLsn and g_instance.archive_obs_cxt.archive_task.targetLsn for deal message with wrong order
|
||||
*/
|
||||
if (archive_task_status->pitr_finish_result == true
|
||||
&& XLByteEQ(archive_task_status->archive_task.targetLsn, targetLsn)) {
|
||||
archive_task_status->pitr_finish_result = false;
|
||||
|
|
|
|||
|
|
@ -685,6 +685,7 @@ static void knl_g_roach_init(knl_g_roach_context* roach_cxt)
|
|||
roach_cxt->targetTimeInPITR = NULL;
|
||||
roach_cxt->globalBarrierRecordForPITR = NULL;
|
||||
roach_cxt->isXLogForceRecycled = false;
|
||||
roach_cxt->forceAdvanceSlotTigger = false;
|
||||
roach_cxt->isGtmFreeCsn = false;
|
||||
roach_cxt->targetRestoreTimeFromMedia = NULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2389,7 +2389,11 @@ Datum gs_pitr_archive_slot_force_advance(PG_FUNCTION_ARGS)
|
|||
signal_child(g_instance.archive_thread_info.obsArchPID[i], SIGUSR2, -1);
|
||||
}
|
||||
}
|
||||
g_instance.roach_cxt.isXLogForceRecycled = false;
|
||||
if (IS_PGXC_COORDINATOR) {
|
||||
g_instance.roach_cxt.isXLogForceRecycled = false;
|
||||
} else {
|
||||
g_instance.roach_cxt.forceAdvanceSlotTigger = true;
|
||||
}
|
||||
rc = snprintf_s(location, MAXFNAMELEN, MAXFNAMELEN - 1, "%08X/%08X",
|
||||
(uint32)(archiveSlotLocNow >> 32), (uint32)(archiveSlotLocNow));
|
||||
securec_check_ss(rc, "\0", "\0");
|
||||
|
|
|
|||
|
|
@ -585,6 +585,9 @@ static void ProcessArchiveXlogMessage(uint32 srcNodeID, const char* msg, uint32
|
|||
static_cast<uint32>(archive_xlog_message->targetLsn))));
|
||||
}
|
||||
volatile unsigned int *pitr_task_status = &archive_task_status->pitr_task_status;
|
||||
if (archive_xlog_message->targetLsn == InvalidXLogRecPtr) {
|
||||
pg_atomic_write_u32(pitr_task_status, PITR_TASK_NONE);
|
||||
}
|
||||
unsigned int expected = PITR_TASK_NONE;
|
||||
int failed_times = 0;
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1908,6 +1908,9 @@ static void ProcessArchiveXlogMessage(const ArchiveXlogMessage* archive_xlog_mes
|
|||
(uint32)(archive_xlog_message->targetLsn))));
|
||||
}
|
||||
volatile unsigned int *pitr_task_status = &archive_task->pitr_task_status;
|
||||
if (archive_xlog_message->targetLsn == InvalidXLogRecPtr) {
|
||||
pg_atomic_write_u32(pitr_task_status, PITR_TASK_NONE);
|
||||
}
|
||||
unsigned int expected = PITR_TASK_NONE;
|
||||
int failed_times = 0;
|
||||
/* lock for archiver get PITR_TASK_GET flag, but works on old task .
|
||||
|
|
|
|||
|
|
@ -1061,6 +1061,7 @@ typedef struct knl_g_roach_context {
|
|||
char* targetTimeInPITR;
|
||||
char* globalBarrierRecordForPITR;
|
||||
bool isXLogForceRecycled;
|
||||
bool forceAdvanceSlotTigger;
|
||||
bool isGtmFreeCsn;
|
||||
char* targetRestoreTimeFromMedia;
|
||||
} knl_g_roach_context;
|
||||
|
|
|
|||
Loading…
Reference in New Issue