mirror of
https://github.com/postgres/postgres.git
synced 2025-07-09 22:41:56 +03:00
Use WaitLatch() instead of pg_usleep() at end-of-vacuum truncation
This has the advantage to make a process more responsive when the postmaster dies, even if the wait time was rather limited as there was only a 50ms timeout here. Another advantage of this change is for monitoring, as we gain a new wait event for the end-of-vacuum truncation. Author: Bharath Rupireddy Reviewed-by: Aleksander Alekseev, Thomas Munro, Michael Paquier Discussion: https://postgr.es/m/CALj2ACU4AdPCq6NLfcA-ZGwX7pPCK5FgEj-CAU0xCKzkASSy_A@mail.gmail.com
This commit is contained in:
@ -3236,7 +3236,11 @@ lazy_truncate_heap(LVRelState *vacrel)
|
||||
return;
|
||||
}
|
||||
|
||||
pg_usleep(VACUUM_TRUNCATE_LOCK_WAIT_INTERVAL * 1000L);
|
||||
(void) WaitLatch(MyLatch,
|
||||
WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
|
||||
VACUUM_TRUNCATE_LOCK_WAIT_INTERVAL,
|
||||
WAIT_EVENT_VACUUM_TRUNCATE);
|
||||
ResetLatch(MyLatch);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -485,6 +485,9 @@ pgstat_get_wait_timeout(WaitEventTimeout w)
|
||||
case WAIT_EVENT_VACUUM_DELAY:
|
||||
event_name = "VacuumDelay";
|
||||
break;
|
||||
case WAIT_EVENT_VACUUM_TRUNCATE:
|
||||
event_name = "VacuumTruncate";
|
||||
break;
|
||||
/* no default case, so that compiler will warn */
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user