Re: [HACKERS] pg_terminate_backend can terminate background workersand autovacuum launchers

Поиск
Список
Период
Сортировка
От Yugo Nagata
Тема Re: [HACKERS] pg_terminate_backend can terminate background workersand autovacuum launchers
Дата
Msg-id 20170622114947.b376bd42.nagata@sraoss.co.jp
обсуждение исходный текст
Ответ на Re: [HACKERS] pg_terminate_backend can terminate background workersand autovacuum launchers  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: [HACKERS] pg_terminate_backend can terminate background workersand autovacuum launchers  (andres@anarazel.de (Andres Freund))
Список pgsql-hackers
On Wed, 21 Jun 2017 11:04:34 -0400
Robert Haas <robertmhaas@gmail.com> wrote:

> On Wed, Jun 21, 2017 at 7:56 AM, Yugo Nagata <nagata@sraoss.co.jp> wrote:
> > I have found that we can cancel/terminate autovacuum launchers and
> > background worker processes by pg_cancel/terminate_backend function.
> > I'm wondering this behavior is not expected and if not I want to fix it.
> 
> I think it is expected.  Even if we blocked it, those processes have
> to cope gracefully with SIGTERM, because anyone with access to the OS
> user can kill them that way by hand.

I agree that we can kill theses processes by the OS command. However,
It seems to me that pg_{cancel,terminate}_backend don't need to be able to
kill processes except for client backends because we can do same thing by
the OS command if necessary, and acutually these functions cannot kill
most other processes, for example, background writer. Are the autovacuum
launcher and background worker special for these functions?

> 
> > However, we can terminate background workers by pg_terminate_backend.
> > In the following example, I terminated the logical replication launcher,
> > and this process did not appear again[1].
> >
> > postgres=# select pg_terminate_backend(30902);
> >  pg_terminate_backend
> > ----------------------
> >  t
> > (1 row)
> 
> That seems to be a bug in logical replication.
> 
> > Similarly, we can terminate autovacuum launcher by pg_terminate_backend,
> > but a new process is restarted by postmaster in this case.[2]
> >
> > postgres=# select pg_terminate_backend(30900);
> >  pg_terminate_backend
> > ----------------------
> >  t
> > (1 row)
> 
> That is as I would expect.
> 
> > [2]
> > On the other hand, when we use pg_cancel_backend for autovacuum launcher,
> > it causes the following error. I'll report the detail in another thread.
> >
> >  ERROR:  can't attach the same segment more than once
> 
> I think that's a bug.
> 
> -- 
> Robert Haas
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company


-- 
Yugo Nagata <nagata@sraoss.co.jp>



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

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: [HACKERS] Get stuck when dropping a subscription duringsynchronizing table
Следующее
От: andres@anarazel.de (Andres Freund)
Дата:
Сообщение: Re: [HACKERS] pg_terminate_backend can terminate background workersand autovacuum launchers