Re: Function to kill backend - Mailing list pgsql-hackers

From Magnus Hagander
Subject Re: Function to kill backend
Date
Msg-id 6BCB9D8A16AC4241919521715F4D8BCE34B6C3@algol.sollentuna.se
Whole thread Raw
In response to Function to kill backend  ("Magnus Hagander" <mha@sollentuna.net>)
Responses Re: Function to kill backend  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> >>> In this case, SIGINT (query cancel) will not help, because
> >>> all locks held by the transaction will still be held.
> >>
> >> Wrong.
>
> > Really?
>
> [ experiments... ]  My apologies --- you are correct about
> the present behavior.  If a SIGINT arrives while waiting for
> client input, it's just dropped on the floor.  The locks
> *will* be dropped if the SIGINT arrives during actual query
> processing.
>
> It strikes me that this is incorrect behavior, at least for
> the case where the client has a transaction block open.  It'd
> be better to define the interrupt as "transaction cancel".

That sounds reasonable. That would certainly solve this part.

That leaves justo ne part of the issue - ability to "kill off" idle
backends. Since they do use up backend "slots" (of which there is a
limited number), I still think this wuold be good. Dunno if it might be
possible to use the same signal for that, under the following scheme:
if (query_running)  cancel_query abort transaction
else if (idle in transaction) abort transaction
else if (idle not in transaction) graceful shutdown

or if that is too confusing? Fromt he "idle not in transaction", it
should be possibleo treat it the same way a "connection lost" would be,
no? (Instead of forcibly going down as SIGTERM does).

With that, I would definitly think limiting to SIGINT would be enough.


A question on using xids for identification instead of PIDs: is there a
xid assigned to a process thati s in the state "idle not in
transaction"? Otherwise, there still needs to be a way to send a signal
to those. I don't see why the PID is not a good idea (assuming
only-backends-restriction, but is even that necessary if you just send
SIGINT?)


//Magnus


pgsql-hackers by date:

Previous
From: jseymour@LinxNet.com (Jim Seymour)
Date:
Subject: Re: Solaris initdb fails: shmmax tweak alternative?
Next
From: Tom Lane
Date:
Subject: Re: Function to kill backend