!980 修复备机归档bug

Merge pull request !980 from Cross-罗/patch_branch
This commit is contained in:
opengauss-bot 2021-05-28 15:44:32 +08:00 committed by Gitee
commit 873d312766
3 changed files with 15 additions and 7 deletions

View File

@ -2477,12 +2477,20 @@ static bool XLogArchiveCheckDone(const char *xlog)
static bool HasBeenArchivedOnHaMode(const char* xlog)
{
load_server_mode();
if (!t_thrd.xlog_cxt.server_mode == PRIMARY_MODE && !t_thrd.xlog_cxt.server_mode == STANDBY_MODE) {
/*
* Generally, the validity of the xlog transferred from the upper layer has been verified.
* Therefore, if the length of the xlog name transferred is greater than the standard length
* of the xlog name (24 characters), the transferred file is a .backup file.
* Therefore, if the xlog name contains more than 24 characters, return true directly.
*/
if (strlen(xlog) > XLOG_NAME_LENGTH) {
return true;
}
load_server_mode();
int mode = t_thrd.xlog_cxt.server_mode;
XLogRecPtr minium_lsn = PG_UINT64_MAX;
for (int i = 0; mode == PRIMARY_MODE && i < g_instance.attr.attr_storage.max_wal_senders; i++) {
/* use volatile pointer to prevent code rearrangement */
volatile WalSnd* walsnd = &t_thrd.walsender_cxt.WalSndCtl->walsnds[i];

View File

@ -140,8 +140,6 @@ static void XLogWalRcvWrite(WalRcvCtlBlock *walrcb, char *buf, Size nbytes, XLog
* would otherwise have to reopen this file to fsync it later
*/
if (recvFile >= 0) {
char xlogfname[MAXFNAMELEN];
/*
* XLOG segment files will be re-read by recovery in startup
* process soon, so we don't advise the OS to release cache
@ -157,6 +155,7 @@ static void XLogWalRcvWrite(WalRcvCtlBlock *walrcb, char *buf, Size nbytes, XLog
* Create .done file forcibly to prevent the restored segment from
* being archived again later.
*/
char xlogfname[MAXFNAMELEN];
XLogFileName(xlogfname, recvFileTLI, recvSegNo);
XLogArchiveForceDone(xlogfname);
#endif

View File

@ -3203,12 +3203,13 @@ static int WalSndLoop(WalSndSendDataCallback send_data)
XLogRecPtr replayPtr;
bool amSync = false;
bool got_recptr = false;
int standby_nums = list_length(SyncRepGetSyncStandbys(&amSync));
got_recptr = SyncRepGetSyncRecPtr(&receivePtr, &writePtr, &flushPtr, &replayPtr, &amSync, false);
if (got_recptr) {
ArchiveXlogOnStandby(flushPtr);
} else if (t_thrd.syncrep_cxt.SyncRepConfig == NULL ||
(t_thrd.walsender_cxt.WalSndCtl->most_available_sync &&
list_length(SyncRepGetSyncStandbys(&amSync)) == 0)) {
} else if (t_thrd.syncrep_cxt.SyncRepConfig == NULL ||
u_sess->attr.attr_storage.guc_synchronous_commit <= SYNCHRONOUS_COMMIT_LOCAL_FLUSH ||
(t_thrd.walsender_cxt.WalSndCtl->most_available_sync && standby_nums == 0)) {
/*
* This step is used to deal with the situation that synchronous standbys are not set.
*/