Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 16fda4b

Browse filesBrowse files
committed
Make error handling in parallel pg_upgrade less bogus.
reap_child() basically ignored the possibility of either an error in waitpid() itself or a child process failure on signal. We don't really need to do more than report and crash hard, but proceeding as though nothing is wrong is definitely Not Acceptable. The error report for nonzero child exit status was pretty off-point, as well. Noted while fooling around with child-process failure detection logic elsewhere. It's been like this a long time, so back-patch to all supported branches.
1 parent ade2d61 commit 16fda4b
Copy full SHA for 16fda4b

File tree

1 file changed

+8
-9
lines changed
Filter options

1 file changed

+8
-9
lines changed

‎src/bin/pg_upgrade/parallel.c

Copy file name to clipboardExpand all lines: src/bin/pg_upgrade/parallel.c
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ reap_child(bool wait_for_child)
290290
{
291291
#ifndef WIN32
292292
int work_status;
293-
int ret;
293+
pid_t child;
294294
#else
295295
int thread_num;
296296
DWORD res;
@@ -300,14 +300,13 @@ reap_child(bool wait_for_child)
300300
return false;
301301

302302
#ifndef WIN32
303-
ret = waitpid(-1, &work_status, wait_for_child ? 0 : WNOHANG);
304-
305-
/* no children or, for WNOHANG, no dead children */
306-
if (ret <= 0 || !WIFEXITED(work_status))
307-
return false;
308-
309-
if (WEXITSTATUS(work_status) != 0)
310-
pg_fatal("child worker exited abnormally: %s\n", strerror(errno));
303+
child = waitpid(-1, &work_status, wait_for_child ? 0 : WNOHANG);
304+
if (child == (pid_t) -1)
305+
pg_fatal("waitpid() failed: %s\n", strerror(errno));
306+
if (child == 0)
307+
return false; /* no children, or no dead children */
308+
if (work_status != 0)
309+
pg_fatal("child process exited abnormally: status %d\n", work_status);
311310
#else
312311
/* wait for one to finish */
313312
thread_num = WaitForMultipleObjects(parallel_jobs, thread_handles,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.