!4516 修复设置catchup2normal_wait_time后性能下降的问题

Merge pull request !4516 from chenxiaobin/fixCatchM
This commit is contained in:
opengauss_bot
2023-12-08 06:04:12 +00:00
committed by Gitee
4 changed files with 9 additions and 3 deletions

View File

@ -1064,6 +1064,7 @@ void knl_instance_init()
g_instance.needCheckConflictSubIds = NIL;
pthread_mutex_init(&g_instance.subIdsLock, NULL);
#endif
g_instance.noNeedWaitForCatchup = 0;
knl_g_datadir_init(&g_instance.datadir_cxt);
knl_g_listen_sock_init(&g_instance.listen_cxt);

View File

@ -174,7 +174,8 @@ bool SynRepWaitCatchup(XLogRecPtr XactCommitLSN)
* return true.
*/
if (!t_thrd.walsender_cxt.WalSndCtl->most_available_sync ||
u_sess->attr.attr_storage.catchup2normal_wait_time < 0) {
u_sess->attr.attr_storage.catchup2normal_wait_time < 0 ||
pg_atomic_read_u32(&g_instance.noNeedWaitForCatchup) == 1) {
return true;
}
@ -956,6 +957,7 @@ static bool SyncRepGetSyncLeftTime(XLogRecPtr XactCommitLSN, TimestampTz* leftTi
num_standbys = SyncRepGetSyncStandbys(&sync_standbys, &catchup_standbys);
/* Skip here if there is at lease one sync standby, or no standby in catchup. */
if (check_sync_standbys_num(sync_standbys, num_standbys) != STANDBIES_EMPTY || list_length(catchup_standbys) == 0) {
pg_atomic_exchange_u32(&g_instance.noNeedWaitForCatchup, 1);
pfree(sync_standbys);
list_free(catchup_standbys);
return false;

View File

@ -6003,10 +6003,12 @@ void WalSndSetState(WalSndState state)
SpinLockAcquire(&walsnd->mutex);
walsnd->state = state;
if (state == WALSNDSTATE_CATCHUP)
if (state == WALSNDSTATE_CATCHUP) {
walsnd->catchupTime[0] = GetCurrentTimestamp();
else if (state == WALSNDSTATE_STREAMING)
pg_atomic_exchange_u32(&g_instance.noNeedWaitForCatchup, 0);
} else if (state == WALSNDSTATE_STREAMING) {
walsnd->catchupTime[1] = GetCurrentTimestamp();
}
SpinLockRelease(&walsnd->mutex);
}

View File

@ -1428,6 +1428,7 @@ typedef struct knl_instance_context {
List* needCheckConflictSubIds;
pthread_mutex_t subIdsLock;
#endif
uint32 noNeedWaitForCatchup;
pg_atomic_uint32 extensionNum;
knl_g_audit_context audit_cxt;
knl_g_abo_context abo_cxt;