Re: Signals in a BGW

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: Signals in a BGW
Дата
Msg-id CAMsr+YF6JOtWYc_vjLJm0KcEoNLuzaKjy4CY_9rswDKA94vhog@mail.gmail.com
обсуждение исходный текст
Ответ на Signals in a BGW  (Chapman Flack <chap@anastigmatix.net>)
Ответы Re: Signals in a BGW  (Michael Paquier <michael.paquier@gmail.com>)
Re: Signals in a BGW  (Chapman Flack <chap@anastigmatix.net>)
Список pgsql-hackers
On 5 December 2017 at 00:40, Chapman Flack wrote: > > Is there a known, default behavior that some signals will > have, if I simply BackgroundWorkerUnblockSignals() without customizing? > Will SIGINT and SIGTERM, for example, have default handlers that > interact with the volatile flags in miscadmin.h that are used by > CHECK_FOR_INTERRUPTS, and set the process latch? > > The default handler is bgworker_die ; see src/backend/postmaster/bgworker.c . I don't know if elog() is safe in a signal handler, but I guess in the absence of non-reentrant errcontext functions... pglogical sets up its own handler 'handle_sigterm'. However, it now does much the same as src/backend/tcop/postgres.c's 'die' function, just without the single-user mode checks. void handle_sigterm(SIGNAL_ARGS) { int save_errno = errno; SetLatch(MyLatch); if (!proc_exit_inprogress) { InterruptPending = true; ProcDiePending = true; } errno = save_errno; } so it's not significantly different. We used to have our own signal handling but it gets seriously messy when you're calling into arbitrary PostgreSQL code that expects CHECK_FOR_INTERRUPTS() to work. > I notice that the worker_spi example code customizes SIGHUP > and SIGTERM, giving them handlers that set a (different, local > to the module) volatile flag, and set the process latch. > IMO it's silly to customise them, and a bad example. Personally I'd rather change the default bgw handler to 'die', make the sample bgworkers use CHECK_FOR_INTERRUPTS() properly, and be done with it. -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Nikita Glukhov
Дата:
Сообщение: Re: [HACKERS] compress method for spgist - 2
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: Signals in a BGW