Skip to content

Commit 1a8aa64

Browse files
committed
Setup SIGUSR1 procsignal_sigusr1_handler handler.
This is normally automatically done when a bgworker declares the BGWORKER_BACKEND_DATABASE_CONNECTION flag, but our bgworker doesn't connect to databases, even though it calls InitPostgres, which will still initialize a new bacckend and thus participate to the ProcSignal infrastructure. This wasn't a problem until recently, but now that DROP DATABASE relies on PROCSIG_BARRIER to work on Windows (see commit 4eb2176318d0561846c1f9fb3c68bede799d640f) we need to respond to ProcSignal notifications.
1 parent 4761667 commit 1a8aa64

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

collector.c

+11
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,16 @@ collector_main(Datum main_arg)
339339
* any equivalent of the backend's command-read loop, where interrupts can
340340
* be processed immediately, so make sure ImmediateInterruptOK is turned
341341
* off.
342+
*
343+
* We also want to respond to the ProcSignal notifications. This is done
344+
* in the upstream provided procsignal_sigusr1_handler, which is
345+
* automatically used if a bgworker connects to a database. But since our
346+
* worker doesn't connect to any database even though it calls
347+
* InitPostgres, which will still initializze a new backend and thus
348+
* partitipate to the ProcSignal infrastructure.
342349
*/
343350
pqsignal(SIGTERM, handle_sigterm);
351+
pqsignal(SIGUSR1, procsignal_sigusr1_handler);
344352
BackgroundWorkerUnblockSignals();
345353

346354
#if PG_VERSION_NUM >= 110000
@@ -379,6 +387,9 @@ collector_main(Datum main_arg)
379387
bool write_history,
380388
write_profile;
381389

390+
/* We need an explicit call for at least ProcSignal notifications. */
391+
CHECK_FOR_INTERRUPTS();
392+
382393
/* Wait calculate time to next sample for history or profile */
383394
current_ts = GetCurrentTimestamp();
384395

0 commit comments

Comments
 (0)