fixed the bug of standby archiving

This commit is contained in:
luozihao
2021-05-27 11:11:54 +08:00
parent b440e0b89d
commit a702316c4d
2 changed files with 15 additions and 3 deletions

View File

@ -2477,9 +2477,20 @@ static bool XLogArchiveCheckDone(const char *xlog)
static bool HasBeenArchivedOnHaMode(const char* xlog)
{
/*
* 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.
*/
if (strlen(xlog) > 24) {
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

@ -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.
*/