mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
Use a WaitLatch for vacuum/autovacuum sleeping
Instead of using pg_usleep() in vacuum_delay_point(), use a WaitLatch. This has the advantage that we will realize if the postmaster has been killed since the last time we decided to sleep while vacuuming. Reviewed-by: Thomas Munro Discussion: https://postgr.es/m/CAFh8B=kcdk8k-Y21RfXPu5dX=bgPqJ8TC3p_qxR_ygdBS=JN5w@mail.gmail.com
This commit is contained in:
@ -2080,9 +2080,11 @@ vacuum_delay_point(void)
|
|||||||
if (msec > VacuumCostDelay * 4)
|
if (msec > VacuumCostDelay * 4)
|
||||||
msec = VacuumCostDelay * 4;
|
msec = VacuumCostDelay * 4;
|
||||||
|
|
||||||
pgstat_report_wait_start(WAIT_EVENT_VACUUM_DELAY);
|
(void) WaitLatch(MyLatch,
|
||||||
pg_usleep((long) (msec * 1000));
|
WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
|
||||||
pgstat_report_wait_end();
|
msec,
|
||||||
|
WAIT_EVENT_VACUUM_DELAY);
|
||||||
|
ResetLatch(MyLatch);
|
||||||
|
|
||||||
VacuumCostBalance = 0;
|
VacuumCostBalance = 0;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user