diff --git a/src/common/backend/port/unix_latch.cpp b/src/common/backend/port/unix_latch.cpp index 0c5b30fa4..0cc4016c2 100644 --- a/src/common/backend/port/unix_latch.cpp +++ b/src/common/backend/port/unix_latch.cpp @@ -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 diff --git a/src/gausskernel/process/postmaster/walwriterauxiliary.cpp b/src/gausskernel/process/postmaster/walwriterauxiliary.cpp index 44028dc2f..e08c7c4c2 100644 --- a/src/gausskernel/process/postmaster/walwriterauxiliary.cpp +++ b/src/gausskernel/process/postmaster/walwriterauxiliary.cpp @@ -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); diff --git a/src/gausskernel/storage/replication/heartbeat.cpp b/src/gausskernel/storage/replication/heartbeat.cpp index c6f410fc9..6eae3a9ee 100644 --- a/src/gausskernel/storage/replication/heartbeat.cpp +++ b/src/gausskernel/storage/replication/heartbeat.cpp @@ -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, µsecs); - 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);