mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +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:
@ -2643,11 +2643,12 @@ die(SIGNAL_ARGS)
|
||||
InterruptHoldoffCount--;
|
||||
ProcessInterrupts();
|
||||
}
|
||||
|
||||
/* Interrupt any sync rep wait which is currently in progress. */
|
||||
SetLatch(&(MyProc->waitLatch));
|
||||
}
|
||||
|
||||
/* If we're still here, waken anything waiting on the process latch */
|
||||
if (MyProc)
|
||||
SetLatch(&MyProc->procLatch);
|
||||
|
||||
errno = save_errno;
|
||||
}
|
||||
|
||||
@ -2684,11 +2685,12 @@ StatementCancelHandler(SIGNAL_ARGS)
|
||||
InterruptHoldoffCount--;
|
||||
ProcessInterrupts();
|
||||
}
|
||||
|
||||
/* Interrupt any sync rep wait which is currently in progress. */
|
||||
SetLatch(&(MyProc->waitLatch));
|
||||
}
|
||||
|
||||
/* If we're still here, waken anything waiting on the process latch */
|
||||
if (MyProc)
|
||||
SetLatch(&MyProc->procLatch);
|
||||
|
||||
errno = save_errno;
|
||||
}
|
||||
|
||||
@ -2696,6 +2698,7 @@ StatementCancelHandler(SIGNAL_ARGS)
|
||||
void
|
||||
FloatExceptionHandler(SIGNAL_ARGS)
|
||||
{
|
||||
/* We're not returning, so no need to save errno */
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FLOATING_POINT_EXCEPTION),
|
||||
errmsg("floating-point exception"),
|
||||
@ -2708,7 +2711,13 @@ FloatExceptionHandler(SIGNAL_ARGS)
|
||||
static void
|
||||
SigHupHandler(SIGNAL_ARGS)
|
||||
{
|
||||
int save_errno = errno;
|
||||
|
||||
got_SIGHUP = true;
|
||||
if (MyProc)
|
||||
SetLatch(&MyProc->procLatch);
|
||||
|
||||
errno = save_errno;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user