mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Allow discovery of whether a dynamic background worker is running.
Using the infrastructure provided by this patch, it's possible either to wait for the startup of a dynamically-registered background worker, or to poll the status of such a worker without waiting. In either case, the current PID of the worker process can also be obtained. As usual, worker_spi is updated to demonstrate the new functionality. Patch by me. Review by Andres Freund.
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
#include "miscadmin.h"
|
||||
#include "storage/latch.h"
|
||||
#include "storage/ipc.h"
|
||||
#include "storage/proc.h"
|
||||
#include "storage/shmem.h"
|
||||
#include "storage/sinval.h"
|
||||
#include "tcop/tcopprot.h"
|
||||
@ -57,6 +58,14 @@ typedef struct
|
||||
*/
|
||||
#define NumProcSignalSlots (MaxBackends + NUM_AUXPROCTYPES)
|
||||
|
||||
/*
|
||||
* If this flag is set, the process latch will be set whenever SIGUSR1
|
||||
* is received. This is useful when waiting for a signal from the postmaster.
|
||||
* Spurious wakeups must be expected. Make sure that the flag is cleared
|
||||
* in the error path.
|
||||
*/
|
||||
bool set_latch_on_sigusr1;
|
||||
|
||||
static ProcSignalSlot *ProcSignalSlots = NULL;
|
||||
static volatile ProcSignalSlot *MyProcSignalSlot = NULL;
|
||||
|
||||
@ -276,6 +285,9 @@ procsignal_sigusr1_handler(SIGNAL_ARGS)
|
||||
if (CheckProcSignal(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN))
|
||||
RecoveryConflictInterrupt(PROCSIG_RECOVERY_CONFLICT_BUFFERPIN);
|
||||
|
||||
if (set_latch_on_sigusr1)
|
||||
SetLatch(&MyProc->procLatch);
|
||||
|
||||
latch_sigusr1_handler();
|
||||
|
||||
errno = save_errno;
|
||||
|
Reference in New Issue
Block a user