fixbug for pgarch thread restart too frequently

Offering: openGaussDev

More detail:

Match-id-02918e510f5ec5f6cf40951eba74dee706324deb
This commit is contained in:
openGaussDev 2022-03-04 15:29:39 +08:00 committed by yanghao
parent 884ea16aa3
commit 3900f93081
2 changed files with 13 additions and 3 deletions

View File

@ -261,7 +261,8 @@ void BarrierPreParseMain(void)
startLSN = XLogFindNextRecord(xlogreader, startLSN);
if (XLogRecPtrIsInvalid(startLSN)) {
startLSN = preStartLSN;
if (!XLByteEQ(walrcv->receiver_flush_location, startLSN)) {
if (!XLByteEQ(walrcv->receiver_flush_location, startLSN) &&
!XLByteEQ(walrcv->lastRecoveredBarrierLSN, startLSN)) {
/* reset startLSN */
startLSN = walrcv->lastRecoveredBarrierLSN;
ereport(LOG, (errmsg("[BarrierPreParse] reset startLSN with lastRecoveredBarrierLSN: %08X/%08X",

View File

@ -425,6 +425,7 @@ static void pgarch_MainLoop(void)
XLogRecPtr replayPtr;
bool got_recptr = false;
bool amSync = false;
int retryTimes = 3;
/* FlushPtr <= ConsensusPtr on DCF mode */
if (IS_PGXC_COORDINATOR || g_instance.attr.attr_storage.dcf_attr.enable_dcf) {
flushPtr = GetFlushRecPtr();
@ -441,8 +442,16 @@ static void pgarch_MainLoop(void)
"and init last lsn is %08X%08X", (uint32)(t_thrd.arch.pitr_task_last_lsn >> 32),
(uint32)t_thrd.arch.pitr_task_last_lsn)));
}
got_recptr = SyncRepGetSyncRecPtr(&receivePtr, &writePtr, &flushPtr, &replayPtr, &amSync, false);
if (got_recptr != true) {
while (retryTimes--) {
got_recptr =
SyncRepGetSyncRecPtr(&receivePtr, &writePtr, &flushPtr, &replayPtr, &amSync, false);
if (got_recptr == true) {
break;
} else {
pg_usleep(1000000L);
}
}
if (got_recptr == false) {
ereport(ERROR,
(errmsg("pgarch_ArchiverObsCopyLoop failed when call SyncRepGetSyncRecPtr")));
}