!837 修复修改系统时间后关闭集群,可能存在的walwriterauxiliary线程长时间阻塞在WaitLatch的问题

Merge pull request !837 from chenxiaobin/stop_fail
This commit is contained in:
opengauss-bot
2021-03-19 10:27:03 +08:00
committed by Gitee
3 changed files with 5 additions and 2 deletions

View File

@ -423,6 +423,8 @@ int WaitLatchOrSocket(volatile Latch* latch, int wakeEvents, pgsocket sock, long
cur_timeout = timeout - (long)INSTR_TIME_GET_MILLISEC(cur_time);
if (cur_timeout < 0) {
cur_timeout = 0;
} else if (cur_timeout > timeout) {
cur_timeout = timeout;
}
#ifndef HAVE_POLL

View File

@ -238,7 +238,7 @@ void WalWriterAuxiliaryMain(void)
}
}
rc = WaitLatch(&t_thrd.proc->procLatch, WL_TIMEOUT | WL_POSTMASTER_DEATH, cur_timeout);
rc = WaitLatch(&t_thrd.proc->procLatch, WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH, cur_timeout);
if (rc & WL_POSTMASTER_DEATH) {
gs_thread_exit(1);

View File

@ -174,11 +174,12 @@ static void delay_control(TimestampTz last_send_time)
TimestampTz now = GetCurrentTimestamp();
TimestampTz timeout = TimestampTzPlusMilliseconds(last_send_time, u_sess->attr.attr_common.dn_heartbeat_interval);
TimestampDifference(now, timeout, &secs, &microsecs);
Assert(secs <= u_sess->attr.attr_common.dn_heartbeat_interval);
/* If has exceeded send_interval, don't delay. */
if (secs == 0 && microsecs == 0) {
return;
} else if (secs > u_sess->attr.attr_common.dn_heartbeat_interval) {
secs = u_sess->attr.attr_common.dn_heartbeat_interval;
}
pg_usleep(secs * USECS_PER_SEC + microsecs);