Re: Cancel/Kill backend functions - Mailing list pgsql-patches

From Magnus Hagander
Subject Re: Cancel/Kill backend functions
Date
Msg-id 6BCB9D8A16AC4241919521715F4D8BCE34BB4B@algol.sollentuna.se
Whole thread Raw
In response to Cancel/Kill backend functions  ("Magnus Hagander" <mha@sollentuna.net>)
Responses Re: Cancel/Kill backend functions  (Neil Conway <neilc@samurai.com>)
List pgsql-patches
>> >> Okay, here is an updated patch. now uses IsBackendPid(), which is
>> >> closely modeled (read cut-and-pasted) from
>> >> TransactionIdIsInProgress().
>
>I wonder what can happen if a backend passes the
>IsBackendPid() test and
>terminates just before the kill() signal?  It should be pretty unlikely
>but you could signal the wrong process ... shouldn't the SInvalLock be
>held throughout the whole operation?

You'd actually need to get a pid *reuse* during that short time.
Otherwise, you're just kill():ing a nonexistant process, which should be
no problem.

This is the same as issuing a "kill -INT <pid>" from the shell after
doing ps(1), which is basically what this function tries to emulate.
Should be no more dangerous than that.

Bottom line -  while maybe slightly more correcet, not sure it's
necessary.

//Magnus

pgsql-patches by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Cancel/Kill backend functions
Next
From: Neil Conway
Date:
Subject: Re: Cancel/Kill backend functions