pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: In the postmaster, rely on the signal infrastructure to block si 5+ messages / 1 participants [nested] [flat]
* pgsql: In the postmaster, rely on the signal infrastructure to block si @ 2019-10-13 19:48 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2019-10-13 19:48 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org In the postmaster, rely on the signal infrastructure to block signals. POSIX sigaction(2) can be told to block a set of signals while a signal handler executes. Make use of that instead of manually blocking and unblocking signals in the postmaster's signal handlers. This should save a few cycles, and it also prevents recursive invocation of signal handlers when many signals arrive in close succession. We have seen buildfarm failures that seem to be due to postmaster stack overflow caused by such recursion (exacerbated by a Linux PPC64 kernel bug). This doesn't change anything about the way that it works on Windows. Somebody might consider adjusting port/win32/signal.c to let it work similarly, but I'm not in a position to do that. For the moment, just apply to HEAD. Possibly we should consider back-patching this, but it'd be good to let it age awhile first. Discussion: https://postgr.es/m/14878.1570820201@sss.pgh.pa.us Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/9abb2bfc046070b22e3be28173a0736da31cab5a Modified Files -------------- src/backend/libpq/pqsignal.c | 49 +++++++++++++++++++++ src/backend/postmaster/postmaster.c | 87 +++++++++++++++++++++++++++---------- src/include/libpq/pqsignal.h | 3 ++ src/include/port.h | 5 --- src/port/pqsignal.c | 29 ------------- 5 files changed, 116 insertions(+), 57 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: In the postmaster, rely on the signal infrastructure to block si @ 2020-10-15 16:51 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2020-10-15 16:51 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org In the postmaster, rely on the signal infrastructure to block signals. POSIX sigaction(2) can be told to block a set of signals while a signal handler executes. Make use of that instead of manually blocking and unblocking signals in the postmaster's signal handlers. This should save a few cycles, but more importantly it prevents recursive invocation of signal handlers when many signals arrive in close succession. (Assuming that the platform's signal infrastructure is designed to avoid consuming stack space in that case, but this is demonstrably true at least on Linux.) The existing code has been seen to recurse to the point of stack overflow, either in the postmaster or in a forked-off child. Back-patch of commit 9abb2bfc0. At the time, we'd only seen excess postmaster stack consumption in the buildfarm; but we now have a user report of it, and that commit has aged enough to have a fair amount of confidence that it doesn't break anything. This still doesn't change anything about the way that it works on Windows. Perhaps someone else would like to fix that? Per bug #16673 from David Geier. Back-patch to 9.6. Although the problem exists in principle before that, we've only seen it actually materialize in connection with heavy use of parallel workers, so it doesn't seem necessary to do anything in 9.5; and the relevant code is different there, too. Discussion: https://postgr.es/m/16673-d278c604f8e34ec0@postgresql.org Discussion: https://postgr.es/m/14878.1570820201@sss.pgh.pa.us Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/85834023a95e16d1d3fe73b0608e1608573753c3 Modified Files -------------- src/backend/libpq/pqsignal.c | 49 +++++++++++++++++++++ src/backend/postmaster/postmaster.c | 87 +++++++++++++++++++++++++++---------- src/include/libpq/pqsignal.h | 3 ++ src/include/port.h | 5 --- src/port/pqsignal.c | 29 ------------- 5 files changed, 116 insertions(+), 57 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: In the postmaster, rely on the signal infrastructure to block si @ 2020-10-15 16:51 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2020-10-15 16:51 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org In the postmaster, rely on the signal infrastructure to block signals. POSIX sigaction(2) can be told to block a set of signals while a signal handler executes. Make use of that instead of manually blocking and unblocking signals in the postmaster's signal handlers. This should save a few cycles, but more importantly it prevents recursive invocation of signal handlers when many signals arrive in close succession. (Assuming that the platform's signal infrastructure is designed to avoid consuming stack space in that case, but this is demonstrably true at least on Linux.) The existing code has been seen to recurse to the point of stack overflow, either in the postmaster or in a forked-off child. Back-patch of commit 9abb2bfc0. At the time, we'd only seen excess postmaster stack consumption in the buildfarm; but we now have a user report of it, and that commit has aged enough to have a fair amount of confidence that it doesn't break anything. This still doesn't change anything about the way that it works on Windows. Perhaps someone else would like to fix that? Per bug #16673 from David Geier. Back-patch to 9.6. Although the problem exists in principle before that, we've only seen it actually materialize in connection with heavy use of parallel workers, so it doesn't seem necessary to do anything in 9.5; and the relevant code is different there, too. Discussion: https://postgr.es/m/16673-d278c604f8e34ec0@postgresql.org Discussion: https://postgr.es/m/14878.1570820201@sss.pgh.pa.us Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/7753ca49d3580454fc55df0ef77cfa87621b56e3 Modified Files -------------- src/backend/libpq/pqsignal.c | 49 ++++++++++++++++++++ src/backend/postmaster/postmaster.c | 89 ++++++++++++++++++++++++++----------- src/include/libpq/pqsignal.h | 3 ++ src/include/port.h | 5 --- src/port/pqsignal.c | 29 ------------ 5 files changed, 116 insertions(+), 59 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: In the postmaster, rely on the signal infrastructure to block si @ 2020-10-15 16:51 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2020-10-15 16:51 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org In the postmaster, rely on the signal infrastructure to block signals. POSIX sigaction(2) can be told to block a set of signals while a signal handler executes. Make use of that instead of manually blocking and unblocking signals in the postmaster's signal handlers. This should save a few cycles, but more importantly it prevents recursive invocation of signal handlers when many signals arrive in close succession. (Assuming that the platform's signal infrastructure is designed to avoid consuming stack space in that case, but this is demonstrably true at least on Linux.) The existing code has been seen to recurse to the point of stack overflow, either in the postmaster or in a forked-off child. Back-patch of commit 9abb2bfc0. At the time, we'd only seen excess postmaster stack consumption in the buildfarm; but we now have a user report of it, and that commit has aged enough to have a fair amount of confidence that it doesn't break anything. This still doesn't change anything about the way that it works on Windows. Perhaps someone else would like to fix that? Per bug #16673 from David Geier. Back-patch to 9.6. Although the problem exists in principle before that, we've only seen it actually materialize in connection with heavy use of parallel workers, so it doesn't seem necessary to do anything in 9.5; and the relevant code is different there, too. Discussion: https://postgr.es/m/16673-d278c604f8e34ec0@postgresql.org Discussion: https://postgr.es/m/14878.1570820201@sss.pgh.pa.us Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/4e95733b08648dbe6c39600521608bdf0cc80f44 Modified Files -------------- src/backend/libpq/pqsignal.c | 49 +++++++++++++++++++++ src/backend/postmaster/postmaster.c | 87 +++++++++++++++++++++++++++---------- src/include/libpq/pqsignal.h | 3 ++ src/include/port.h | 5 --- src/port/pqsignal.c | 29 ------------- 5 files changed, 116 insertions(+), 57 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: In the postmaster, rely on the signal infrastructure to block si @ 2020-10-15 16:51 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 5+ messages in thread From: Tom Lane @ 2020-10-15 16:51 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org In the postmaster, rely on the signal infrastructure to block signals. POSIX sigaction(2) can be told to block a set of signals while a signal handler executes. Make use of that instead of manually blocking and unblocking signals in the postmaster's signal handlers. This should save a few cycles, but more importantly it prevents recursive invocation of signal handlers when many signals arrive in close succession. (Assuming that the platform's signal infrastructure is designed to avoid consuming stack space in that case, but this is demonstrably true at least on Linux.) The existing code has been seen to recurse to the point of stack overflow, either in the postmaster or in a forked-off child. Back-patch of commit 9abb2bfc0. At the time, we'd only seen excess postmaster stack consumption in the buildfarm; but we now have a user report of it, and that commit has aged enough to have a fair amount of confidence that it doesn't break anything. This still doesn't change anything about the way that it works on Windows. Perhaps someone else would like to fix that? Per bug #16673 from David Geier. Back-patch to 9.6. Although the problem exists in principle before that, we've only seen it actually materialize in connection with heavy use of parallel workers, so it doesn't seem necessary to do anything in 9.5; and the relevant code is different there, too. Discussion: https://postgr.es/m/16673-d278c604f8e34ec0@postgresql.org Discussion: https://postgr.es/m/14878.1570820201@sss.pgh.pa.us Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/8b53dbada4a6a9e5f16548ca2c4d17cff55933d8 Modified Files -------------- src/backend/libpq/pqsignal.c | 49 +++++++++++++++++++++ src/backend/postmaster/postmaster.c | 87 +++++++++++++++++++++++++++---------- src/include/libpq/pqsignal.h | 3 ++ src/include/port.h | 5 --- src/port/pqsignal.c | 29 ------------- 5 files changed, 116 insertions(+), 57 deletions(-) ^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2020-10-15 16:51 UTC | newest] Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-10-13 19:48 pgsql: In the postmaster, rely on the signal infrastructure to block si Tom Lane <tgl@sss.pgh.pa.us> 2020-10-15 16:51 pgsql: In the postmaster, rely on the signal infrastructure to block si Tom Lane <tgl@sss.pgh.pa.us> 2020-10-15 16:51 pgsql: In the postmaster, rely on the signal infrastructure to block si Tom Lane <tgl@sss.pgh.pa.us> 2020-10-15 16:51 pgsql: In the postmaster, rely on the signal infrastructure to block si Tom Lane <tgl@sss.pgh.pa.us> 2020-10-15 16:51 pgsql: In the postmaster, rely on the signal infrastructure to block si 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