mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Change the autovacuum launcher to use WaitLatch instead of a poll loop.
In pursuit of this (and with the expectation that WaitLatch will be needed in more places), convert the latch field that was already added to PGPROC for sync rep into a generic latch that is activated for all PGPROC-owning processes, and change many of the standard backend signal handlers to set that latch when a signal happens. This will allow WaitLatch callers to be wakened properly by these signals. In passing, fix a whole bunch of signal handlers that had been hacked to do things that might change errno, without adding the necessary save/restore logic for errno. Also make some minor fixes in unix_latch.c, and clean up bizarre and unsafe scheme for disowning the process's latch. Much of this has to be back-patched into 9.1. Peter Geoghegan, with additional work by Tom
This commit is contained in:
@@ -288,16 +288,21 @@ pgarch_exit(SIGNAL_ARGS)
|
||||
static void
|
||||
ArchSigHupHandler(SIGNAL_ARGS)
|
||||
{
|
||||
int save_errno = errno;
|
||||
|
||||
/* set flag to re-read config file at next convenient time */
|
||||
got_SIGHUP = true;
|
||||
/* let the waiting loop iterate */
|
||||
SetLatch(&mainloop_latch);
|
||||
|
||||
errno = save_errno;
|
||||
}
|
||||
|
||||
/* SIGTERM signal handler for archiver process */
|
||||
static void
|
||||
ArchSigTermHandler(SIGNAL_ARGS)
|
||||
{
|
||||
int save_errno = errno;
|
||||
|
||||
/*
|
||||
* The postmaster never sends us SIGTERM, so we assume that this means
|
||||
* that init is trying to shut down the whole system. If we hang around
|
||||
@@ -305,28 +310,35 @@ ArchSigTermHandler(SIGNAL_ARGS)
|
||||
* archive commands.
|
||||
*/
|
||||
got_SIGTERM = true;
|
||||
/* let the waiting loop iterate */
|
||||
SetLatch(&mainloop_latch);
|
||||
|
||||
errno = save_errno;
|
||||
}
|
||||
|
||||
/* SIGUSR1 signal handler for archiver process */
|
||||
static void
|
||||
pgarch_waken(SIGNAL_ARGS)
|
||||
{
|
||||
int save_errno = errno;
|
||||
|
||||
/* set flag that there is work to be done */
|
||||
wakened = true;
|
||||
/* let the waiting loop iterate */
|
||||
SetLatch(&mainloop_latch);
|
||||
|
||||
errno = save_errno;
|
||||
}
|
||||
|
||||
/* SIGUSR2 signal handler for archiver process */
|
||||
static void
|
||||
pgarch_waken_stop(SIGNAL_ARGS)
|
||||
{
|
||||
int save_errno = errno;
|
||||
|
||||
/* set flag to do a final cycle and shut down afterwards */
|
||||
ready_to_stop = true;
|
||||
/* let the waiting loop iterate */
|
||||
SetLatch(&mainloop_latch);
|
||||
|
||||
errno = save_errno;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user