git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 54bb91c)
Use a WaitLatch for vacuum/autovacuum sleeping
2021年3月30日 16:52:56 +0000 (12:52 -0400)
2021年3月30日 16:52:56 +0000 (12:52 -0400)
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


diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index c064352e237fb7468651f0dad5c58d8b5d017481..662aff04b45561ed8c6fdea92b8494a8b5ad5e7a 100644 (file)
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -2080,9 +2080,11 @@ vacuum_delay_point(void)
if (msec > VacuumCostDelay * 4)
msec = VacuumCostDelay * 4;
- pgstat_report_wait_start(WAIT_EVENT_VACUUM_DELAY);
- pg_usleep((long) (msec * 1000));
- pgstat_report_wait_end();
+ (void) WaitLatch(MyLatch,
+ WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
+ msec,
+ WAIT_EVENT_VACUUM_DELAY);
+ ResetLatch(MyLatch);
VacuumCostBalance = 0;
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /