pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Clean up thread management in parallel pg_dump for Windows. 4+ messages / 1 participants [nested] [flat]
* pgsql: Clean up thread management in parallel pg_dump for Windows. @ 2016-05-27 16:02 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2016-05-27 16:02 UTC (permalink / raw) To: pgsql-committers Clean up thread management in parallel pg_dump for Windows. Since we start the worker threads with _beginthreadex(), we should use _endthreadex() to terminate them. We got this right in the normal-exit code path, but not so much during an error exit from a worker. In addition, be sure to apply CloseHandle to the thread handle after each thread exits. It's not clear that these oversights cause any user-visible problems, since the pg_dump run is about to terminate anyway. Still, it's clearly better to follow Microsoft's API specifications than ignore them. Also a few cosmetic cleanups in WaitForTerminatingWorkers(), including being a bit less random about where to cast between uintptr_t and HANDLE, and being sure to clear the worker identity field for each dead worker (not that false matches should be possible later, but let's be careful). Original observation and patch by Armin Schöffmann, cosmetic improvements by Michael Paquier and me. (Armin's patch also included closing sockets in ShutdownWorkersHard(), but that's been dealt with already in commit df8d2d8c4.) Back-patch to 9.3 where parallel pg_dump was introduced. Discussion: <zarafa.570306bd.3418.074bf1420d8f2ba2@root.aegaeon.de> Branch ------ master Details ------- http://git.postgresql.org/pg/commitdiff/807b45375beae6563c3833e72d91869e9b9134e5 Modified Files -------------- src/bin/pg_dump/parallel.c | 53 ++++++++++++++++++++++++++------------- src/bin/pg_dump/pg_backup_utils.c | 2 +- 2 files changed, 37 insertions(+), 18 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Clean up thread management in parallel pg_dump for Windows. @ 2016-05-27 16:02 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2016-05-27 16:02 UTC (permalink / raw) To: pgsql-committers Clean up thread management in parallel pg_dump for Windows. Since we start the worker threads with _beginthreadex(), we should use _endthreadex() to terminate them. We got this right in the normal-exit code path, but not so much during an error exit from a worker. In addition, be sure to apply CloseHandle to the thread handle after each thread exits. It's not clear that these oversights cause any user-visible problems, since the pg_dump run is about to terminate anyway. Still, it's clearly better to follow Microsoft's API specifications than ignore them. Also a few cosmetic cleanups in WaitForTerminatingWorkers(), including being a bit less random about where to cast between uintptr_t and HANDLE, and being sure to clear the worker identity field for each dead worker (not that false matches should be possible later, but let's be careful). Original observation and patch by Armin Schöffmann, cosmetic improvements by Michael Paquier and me. (Armin's patch also included closing sockets in ShutdownWorkersHard(), but that's been dealt with already in commit df8d2d8c4.) Back-patch to 9.3 where parallel pg_dump was introduced. Discussion: <zarafa.570306bd.3418.074bf1420d8f2ba2@root.aegaeon.de> Branch ------ REL9_4_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/20766315cd87a557ea6575ab8475c771b5e6cf77 Modified Files -------------- src/bin/pg_dump/parallel.c | 53 ++++++++++++++++++++++++++------------- src/bin/pg_dump/pg_backup_utils.c | 2 +- 2 files changed, 37 insertions(+), 18 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Clean up thread management in parallel pg_dump for Windows. @ 2016-05-27 16:02 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2016-05-27 16:02 UTC (permalink / raw) To: pgsql-committers Clean up thread management in parallel pg_dump for Windows. Since we start the worker threads with _beginthreadex(), we should use _endthreadex() to terminate them. We got this right in the normal-exit code path, but not so much during an error exit from a worker. In addition, be sure to apply CloseHandle to the thread handle after each thread exits. It's not clear that these oversights cause any user-visible problems, since the pg_dump run is about to terminate anyway. Still, it's clearly better to follow Microsoft's API specifications than ignore them. Also a few cosmetic cleanups in WaitForTerminatingWorkers(), including being a bit less random about where to cast between uintptr_t and HANDLE, and being sure to clear the worker identity field for each dead worker (not that false matches should be possible later, but let's be careful). Original observation and patch by Armin Schöffmann, cosmetic improvements by Michael Paquier and me. (Armin's patch also included closing sockets in ShutdownWorkersHard(), but that's been dealt with already in commit df8d2d8c4.) Back-patch to 9.3 where parallel pg_dump was introduced. Discussion: <zarafa.570306bd.3418.074bf1420d8f2ba2@root.aegaeon.de> Branch ------ REL9_3_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/8b97208ecb44f41d159237822f4fa7214075ea75 Modified Files -------------- src/bin/pg_dump/parallel.c | 53 ++++++++++++++++++++++++++------------- src/bin/pg_dump/pg_backup_utils.c | 2 +- 2 files changed, 37 insertions(+), 18 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 4+ messages in thread
* pgsql: Clean up thread management in parallel pg_dump for Windows. @ 2016-05-27 16:02 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 4+ messages in thread From: Tom Lane @ 2016-05-27 16:02 UTC (permalink / raw) To: pgsql-committers Clean up thread management in parallel pg_dump for Windows. Since we start the worker threads with _beginthreadex(), we should use _endthreadex() to terminate them. We got this right in the normal-exit code path, but not so much during an error exit from a worker. In addition, be sure to apply CloseHandle to the thread handle after each thread exits. It's not clear that these oversights cause any user-visible problems, since the pg_dump run is about to terminate anyway. Still, it's clearly better to follow Microsoft's API specifications than ignore them. Also a few cosmetic cleanups in WaitForTerminatingWorkers(), including being a bit less random about where to cast between uintptr_t and HANDLE, and being sure to clear the worker identity field for each dead worker (not that false matches should be possible later, but let's be careful). Original observation and patch by Armin Schöffmann, cosmetic improvements by Michael Paquier and me. (Armin's patch also included closing sockets in ShutdownWorkersHard(), but that's been dealt with already in commit df8d2d8c4.) Back-patch to 9.3 where parallel pg_dump was introduced. Discussion: <zarafa.570306bd.3418.074bf1420d8f2ba2@root.aegaeon.de> Branch ------ REL9_5_STABLE Details ------- http://git.postgresql.org/pg/commitdiff/715db0b73926c7e591aaa2552b429a0cd793e200 Modified Files -------------- src/bin/pg_dump/parallel.c | 53 ++++++++++++++++++++++++++------------- src/bin/pg_dump/pg_backup_utils.c | 2 +- 2 files changed, 37 insertions(+), 18 deletions(-) -- Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-committers ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2016-05-27 16:02 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2016-05-27 16:02 pgsql: Clean up thread management in parallel pg_dump for Windows. Tom Lane <tgl@sss.pgh.pa.us> 2016-05-27 16:02 pgsql: Clean up thread management in parallel pg_dump for Windows. Tom Lane <tgl@sss.pgh.pa.us> 2016-05-27 16:02 pgsql: Clean up thread management in parallel pg_dump for Windows. Tom Lane <tgl@sss.pgh.pa.us> 2016-05-27 16:02 pgsql: Clean up thread management in parallel pg_dump for Windows. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox