Thread: pgsql: Use signals for postmaster death on Linux.
Use signals for postmaster death on Linux. Linux provides a way to ask for a signal when your parent process dies. Use that to make PostmasterIsAlive() very cheap. Based on a suggestion from Andres Freund. Author: Thomas Munro, Heikki Linnakangas Reviewed-By: Michael Paquier Discussion: https://postgr.es/m/7261eb39-0369-f2f4-1bb5-62f3b6083b5e%40iki.fi Discussion: https://postgr.es/m/20180411002643.6buofht4ranhei7k%40alap3.anarazel.de Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/9f09529952ac41a10e5874cba745c1c24e67ac79 Modified Files -------------- configure | 2 +- configure.in | 2 +- src/backend/storage/ipc/latch.c | 6 +- src/backend/storage/ipc/pmsignal.c | 125 +++++++++++++++++++++++++++++++++---- src/backend/utils/init/miscinit.c | 4 ++ src/include/pg_config.h.in | 3 + src/include/pg_config.h.win32 | 3 + src/include/storage/pmsignal.h | 33 +++++++++- 8 files changed, 159 insertions(+), 19 deletions(-)
Thomas Munro <tmunro@postgresql.org> writes: > Use signals for postmaster death on Linux. One or the other of these patches seems to have caused pmsignal.h to fail to compile standalone: ./src/include/storage/pmsignal.h:79: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'postmaster_possibly_dead' ./src/include/storage/pmsignal.h: In function 'PostmasterIsAlive': ./src/include/storage/pmsignal.h:84: error: 'postmaster_possibly_dead' undeclared (first use in this function) ./src/include/storage/pmsignal.h:84: error: (Each undeclared identifier is reported only once ./src/include/storage/pmsignal.h:84: error: for each function it appears in.) Apparently, this header needs a reference to wherever sig_atomic_t is declared. regards, tom lane
On Thu, Aug 2, 2018 at 8:07 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote: > Thomas Munro <tmunro@postgresql.org> writes: >> Use signals for postmaster death on Linux. > > One or the other of these patches seems to have caused pmsignal.h > to fail to compile standalone: > > ./src/include/storage/pmsignal.h:79: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'postmaster_possibly_dead' > ./src/include/storage/pmsignal.h: In function 'PostmasterIsAlive': > ./src/include/storage/pmsignal.h:84: error: 'postmaster_possibly_dead' undeclared (first use in this function) > ./src/include/storage/pmsignal.h:84: error: (Each undeclared identifier is reported only once > ./src/include/storage/pmsignal.h:84: error: for each function it appears in.) > > Apparently, this header needs a reference to wherever sig_atomic_t > is declared. Thanks, will fix. -- Thomas Munro http://www.enterprisedb.com