Re: Cancelling Requests Frontend/Backend Protocol TCP/IP

From: Raimon Fernandez <coder(at)montx(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Cancelling Requests Frontend/Backend Protocol TCP/IP
Date: 2009-11-02 15:50:49
Message-ID: 0E251CE4-7C54-4D67-8F2E-4EA05DF2F424@montx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-interfaces


On 02/11/2009, at 15:38, Tom Lane wrote:

> Craig Ringer <craig(at)postnewspapers(dot)com(dot)au> writes:
>> On 2/11/2009 5:15 PM, Raimon Fernandez wrote:
>>> If for example I send a SELECT * from myTable, it has 20000 rows,
>>> and
>>> postgre starts sending the rows, how I can cancel this operation ?
>
>> Assuming you're asking "is there any way to cancel a running query
>> using
>> the postgresql tcp/ip protocol" then, as you've noted, you can cancel
>> the request until you start getting data.
>
>> After that, you can still cancel the query by establishing another
>> connection to the server and calling pg_cancel_backend( ) at the SQL
>> level. This does, unfortunately, involve the overhead of setting up
>> and
>> tearing down a connection and the associated backend.
>
> The above distinction is nonsense. Query cancel works the same way
> whether you have started receiving data or not --- it will open a
> transient connection in any case. Otherwise there would be race
> condition problems if the backend is just about to start sending data.

So my approach of sending only the CancelRequest should work ?

Always from a new connection, before sending the StartUpSequence, just
open, connect and send it ?

Quoted from the documentation:

"The cancellation signal might or might not have any effect — for
example, if it arrives after the
backend has finished processing the query, then it will have no
effect. If the cancellation is effective,
it results in the current command being terminated early with an error
message. "

Here I understand that maybe it will have NO effect, so postgresql
will still sending rows and rows and rows ...

thanks,

regards,

raimon

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raimon Fernandez 2009-11-02 15:52:15 Re: Cancelling Requests Frontend/Backend Protocol TCP/IP
Previous Message Sam Mason 2009-11-02 15:09:14 Re: array_reverse()

Browse pgsql-interfaces by date

  From Date Subject
Next Message Raimon Fernandez 2009-11-02 15:52:15 Re: Cancelling Requests Frontend/Backend Protocol TCP/IP
Previous Message Tom Lane 2009-11-02 14:38:00 Re: Cancelling Requests Frontend/Backend Protocol TCP/IP