Re: Function to kill backend

From: Thomas Swan <tswan(at)idigx(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <mha(at)sollentuna(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Function to kill backend
Date: 2004-04-07 01:44:58
Message-ID: 40735D1A.6010606@idigx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Bruce Momjian wrote:

>pgman wrote:
>
>
>>Josh Berkus wrote:
>>
>>
>>>Tom,
>>>
>>>
>>>
>>>>I don't think it's an open-and-shut decision as to whether people
>>>>actually *need* to do session kills (as opposed to query/transaction
>>>>kills). The arguments presented so far are not convincing to my mind,
>>>>certainly not convincing enough to buy into a commitment to do whatever
>>>>it takes to support that.
>>>>
>>>>
>>>Hmmm ... well, I can make a real-world case from my supported apps for
>>>transaction/statement kills. But my support for session kills is just
>>>hypothetical; any time I've had to kill off sessions, it's because I had to
>>>shut the database down, and that's better done from the command line.
>>>
>>>My web apps which need to manage the number of connections do it through their
>>>connection pool.
>>>
>>>So I would vote for Yes on SIGINT by XID, but No on SIGTERM by PID, if Tom
>>>thinks there will be any significant support & troubleshooting involved for
>>>the latter.
>>>
>>>Unless, of course, someone can give us a real business case that they have
>>>actually encountered in production.
>>>
>>>
>>Someone already posted some pseudocode where they wanted to kill idle
>>backends, perhaps as part of connection pooling.
>>
>>
>
>Tom, if you have concerns about SIGTERM while other backends keep
>running, would you share those. (Holding locks, shared memory?) I
>looked at die(), and it seemed pretty safe to me. It just sets some
>variables and returns. It is not like quickdie that calls exit().
>
>If there is a problem, maybe we can fix it, or perhap have the kill
>function use SIGINT, then wait for the query to cancel, then SIGTERM.
>
>
>
One other option to consider while your looking at killing off children
as an admin is the ability to switch the database to single user mode
for the admin via psql or other connection interface. In essence
shutdown all other transactions and session and limit it to only one so
that maintenance issues (reindexing, etc) can be done remotely and do
not require shell access on the host machine.

I think, ultimately, this may be what is being asked for: a way to
manage postgresql internally via SQL or other functions rather than
relying on user access to the machine (ie sending signals to
processes). This is what some people have wanted to do with managing
the connection settings in pg_hba.conf via a system table rather than or
in addition to a file.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message wespvp 2004-04-07 03:50:24 Re: thread_test.c problems
Previous Message Dan Graham 2004-04-07 01:35:22 LIKE vs regex queries

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2004-04-07 05:05:51 Re: [HACKERS] logging statement levels
Previous Message Dan Graham 2004-04-07 01:35:22 LIKE vs regex queries