From a2177fdb0896160f209db4eebc5b4d80eb341e42 Mon Sep 17 00:00:00 2001 From: Vignesh C Date: Fri, 3 Jul 2020 12:18:55 +0530 Subject: [PATCH] Fix for Parallel worker hangs while handling errors. Worker is not able to receive the signals while processing error flow. Worker hangs in this case because when the worker is started the signals will be masked using sigprocmask. Unblocking of signals is done by calling BackgroundWorkerUnblockSignals in ParallelWorkerMain. Now due to error handling the worker has jumped to setjmp in StartBackgroundWorker function. Here the signals are in blocked state, hence the signal is not received by the worker process. --- src/backend/postmaster/bgworker.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c index beb5e85..9663907 100644 --- a/src/backend/postmaster/bgworker.c +++ b/src/backend/postmaster/bgworker.c @@ -747,6 +747,11 @@ StartBackgroundWorker(void) */ if (sigsetjmp(local_sigjmp_buf, 1) != 0) { + /* + * Unblock signals (they were blocked when the postmaster forked us) + */ + BackgroundWorkerUnblockSignals(); + /* Since not using PG_TRY, must reset error stack by hand */ error_context_stack = NULL; -- 1.8.3.1