Skip to content

Commit 4753ef3

Browse files
committed
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
1 parent 54bb91c commit 4753ef3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/backend/commands/vacuum.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,9 +2080,11 @@ vacuum_delay_point(void)
20802080
if (msec > VacuumCostDelay * 4)
20812081
msec = VacuumCostDelay * 4;
20822082

2083-
pgstat_report_wait_start(WAIT_EVENT_VACUUM_DELAY);
2084-
pg_usleep((long) (msec * 1000));
2085-
pgstat_report_wait_end();
2083+
(void) WaitLatch(MyLatch,
2084+
WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
2085+
msec,
2086+
WAIT_EVENT_VACUUM_DELAY);
2087+
ResetLatch(MyLatch);
20862088

20872089
VacuumCostBalance = 0;
20882090

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy