Skip to content

Commit 82dd373

Browse files
committed
Avoid lockup of a parallel worker when reporting a long error message.
Because sigsetjmp() will restore the initial state with signals blocked, the code path in bgworker.c for reporting an error and exiting would execute that way. Usually this is fairly harmless; but if a parallel worker had an error message exceeding the shared-memory communication buffer size (16K) it would lock up, because it would wait for a resume-sending signal from its parallel leader which it would never detect. To fix, just unblock signals at the appropriate point. This can be shown to fail back to 9.6. The lack of parallel query infrastructure makes it difficult to provide a simple test case for 9.5; but I'm pretty sure the issue exists in some form there as well, so apply the code change there too. Vignesh C, reviewed by Bharath Rupireddy, Robert Haas, and myself Discussion: https://postgr.es/m/CALDaNm1d1hHPZUg3xU4XjtWBOLCrA+-2cJcLpw-cePZ=GgDVfA@mail.gmail.com
1 parent fcc4275 commit 82dd373

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/backend/postmaster/bgworker.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ StartBackgroundWorker(void)
764764
/*
765765
* If an exception is encountered, processing resumes here.
766766
*
767-
* See notes in postgres.c about the design of this coding.
767+
* We just need to clean up, report the error, and go away.
768768
*/
769769
if (sigsetjmp(local_sigjmp_buf, 1) != 0)
770770
{
@@ -774,7 +774,14 @@ StartBackgroundWorker(void)
774774
/* Prevent interrupts while cleaning up */
775775
HOLD_INTERRUPTS();
776776

777-
/* Report the error to the server log */
777+
/*
778+
* sigsetjmp will have blocked all signals, but we may need to accept
779+
* signals while communicating with our parallel leader. Once we've
780+
* done HOLD_INTERRUPTS() it should be safe to unblock signals.
781+
*/
782+
BackgroundWorkerUnblockSignals();
783+
784+
/* Report the error to the parallel leader and the server log */
778785
EmitErrorReport();
779786

780787
/*

0 commit comments

Comments
 (0)