Thread: how to cancel a request in progress ?

how to cancel a request in progress ?

From
Jonathan Davis
Date:
hello all

is this possible to cancel a request in progress ?


Re: [GENERAL] how to cancel a request in progress ?

From
Simon Drabble
Date:
On Tue, 25 May 1999, Jonathan Davis wrote:

> hello all
>
> is this possible to cancel a request in progress ?
>
>

If you are using the interactive monitor, psql, try ctrl-c.

If you are using the libpq or other interface, then it becomes much more
application specific, i.e. you might have to kill off the app.


Simon.


--
  "The world will end at Dec 31 1999 23:59:59. Please save your work and log
   off before then or risk losing your data."

   Simon Drabble                      Somewhere in cyberspace
   simond@foxlink.net


Re: [GENERAL] how to cancel a request in progress ?

From
Jonathan Davis
Date:
Simon Drabble wrote:

> On Tue, 25 May 1999, Jonathan Davis wrote:
>
> > hello all
> >
> > is this possible to cancel a request in progress ?
> >
> >
>
> If you are using the interactive monitor, psql, try ctrl-c.
>
> If you are using the libpq or other interface, then it becomes much more
> application specific, i.e. you might have to kill off the app.
>

but how do you kill a request  in progress?

>
> Simon.
>

I 'm using the libpq,.




Re: [GENERAL] how to cancel a request in progress ?

From
Simon Drabble
Date:
On Tue, 25 May 1999, Jonathan Davis wrote:

> Simon Drabble wrote:
>
> > On Tue, 25 May 1999, Jonathan Davis wrote:
> >
> > > hello all
> > >
> > > is this possible to cancel a request in progress ?
> > >
> > >
> >
> > If you are using the interactive monitor, psql, try ctrl-c.
> >
> > If you are using the libpq or other interface, then it becomes much more
> > application specific, i.e. you might have to kill off the app.
> >
>
> but how do you kill a request  in progress?
>
> I 'm using the libpq,.
>

Kill it off without killing the ap you mean? Unless your app is multi-threaded
or multi-process and uses IPC, you might not be able to.

You can use the asynch access functions within libpq, which will give control
back to your program. If you then decide at a later point that the database
command has not returned, you can kill it off if it is within a subthread or
subprocess (from a fork(), e.g.) but AFAIK there is no libpq or postgres
function to terminate a running command.

Actually it might be a better idea have your subprocess handle the db request
synchronously, and then the parent can time it out if it takes too long and
send a signal to the child to terminate it. This could be quite messy,
however, so if you are doing inserts or anything which affects a table's
contents, I would wrap it in a BEGIN..END transaction.


Simon.

--
  "The world will end at Dec 31 1999 23:59:59. Please save your work and log
   off before then or risk losing your data."

   Simon Drabble                      Somewhere in cyberspace
   simond@foxlink.net


Re: [GENERAL] how to cancel a request in progress ?

From
Jonathan Davis
Date:
Jonathan Davis wrote:

> Simon Drabble wrote:
>
> > On Tue, 25 May 1999, Jonathan Davis wrote:
> >
> > > hello all
> > >
> > > is this possible to cancel a request in progress ?
> > >
> > >
> >
> > If you are using the interactive monitor, psql, try ctrl-c.
> >
> > If you are using the libpq or other interface, then it becomes much more
> > application specific, i.e. you might have to kill off the app.
> >
>
> but how do you kill a request  in progress?
>
> >
> > Simon.
> >
>
> I 'm using the libpq,.

it is possible by :  PQrequestCancel  but you must use the  Asynchronous
Query Processing
(PQsendQuery/PQgetResult).




Re: [GENERAL] how to cancel a request in progress ?

From
Simon Drabble
Date:
On Tue, 25 May 1999, Jonathan Davis wrote:

> Jonathan Davis wrote:
>
> > Simon Drabble wrote:
> >
> > > On Tue, 25 May 1999, Jonathan Davis wrote:
> > >
> > > > hello all
> > > >
> > > > is this possible to cancel a request in progress ?
> > > >
> > > >
> > >
> > > If you are using the interactive monitor, psql, try ctrl-c.
> > >
> > > If you are using the libpq or other interface, then it becomes much more
> > > application specific, i.e. you might have to kill off the app.
> > >
> >
> > but how do you kill a request  in progress?
> >
> > >
> > > Simon.
> > >
> >
> > I 'm using the libpq,.
>
> it is possible by :  PQrequestCancel  but you must use the  Asynchronous
> Query Processing
> (PQsendQuery/PQgetResult).
>
>
>
>
>

--
  "The world will end at Dec 31 1999 23:59:59. Please save your work and log
   off before then or risk losing your data."

   Simon Drabble                      Somewhere in cyberspace
   simond@foxlink.net


Re: [GENERAL] how to cancel a request in progress ?

From
"Michael A. Koerber"
Date:
It isn't pretty, but as 'su' or 'postgres' you can kill the the "postmaster pid".
However, you may have to clean up 'junk files' left in the data base.  Don't do
this except as a last resort.

mike

--
-------------------------------------------------------
It said use Windows 95 or better, so I installed Linux!
--
Dr Michael A. Koerber
MIT/Lincoln Laboratory
781-981-3250
-------------------------------------------------------

Re: [GENERAL] how to cancel a request in progress ?

From
Simon Drabble
Date:
On Tue, 24 May 1999, Michael A. Koerber wrote:

> It isn't pretty, but as 'su' or 'postgres' you can kill the the "postmaster pid".
> However, you may have to clean up 'junk files' left in the data base.  Don't do
> this except as a last resort.
>
> mike
>
> --
> -------------------------------------------------------
> It said use Windows 95 or better, so I installed Linux!
> --
> Dr Michael A. Koerber
> MIT/Lincoln Laboratory
> 781-981-3250
> -------------------------------------------------------
>

Hmmm. Sledgehammer, this is nut. Nut, meet sledgehammer. :)

Jonathan found the optimal solution - PQrequestCancel() from within the app.

Simon.




--
  "The world will end at Dec 31 1999 23:59:59. Please save your work and log
   off before then or risk losing your data."

   Simon Drabble                      Somewhere in cyberspace
   simond@foxlink.net



Re: [GENERAL] how to cancel a request in progress ?

From
jerome doucerain
Date:

Jonathan Davis a écrit :

> hello all
>
> is this possible to cancel a request in progress ?

It may be interesting to have a look at the programmer's guide Postgres
Signals :
if you want to cancel a request you may kill -SIGINT the backend process
running the request.
In this case, the postmaster and the others backend processes keep on
running.
Jerome