pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Niall Ross <niallfr@btinternet.com>
Cc: Kevin Grittner <kgrittn@ymail.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: BUG #13518: CancelRequest lacks statement identifier
Date: Wed, 29 Jul 2015 12:00:27 -0400
Message-ID: <31145.1438185627@sss.pgh.pa.us> (raw)
In-Reply-To: <55B7F554.7040700@btinternet.com>
References: <20150724180236.2737.27011@wrigleys.postgresql.org>
	<773925395.3977925.1438112478191.JavaMail.yahoo@mail.yahoo.com>
	<26896.1438113446@sss.pgh.pa.us>
	<55B7F554.7040700@btinternet.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Niall Ross <niallfr@btinternet.com> writes:
> Am I misunderstanding something?  My experience with using Postgres, and 
> my reading of the documents, is that a new statement, but not a new 
> connection, is needed to cancel a statement on that connection.  The 
> cancel is signalled by a fresh statement using the same connection (and 
> specifically that connection's PID and Key).

Uh, no, that's not how it works at all.  PQcancel() involves opening a
fresh connection to the postmaster, which will then send SIGINT to the
backend process you're originally connected to.

Also, looking again at the PQcancel code, I'm unsure that there is any
actual race condition here.  The comments therein quoth

     * Wait for the postmaster to close the connection, which indicates that
     * it's processed the request.  Without this delay, we might issue another
     * command only to find that our cancel zaps that command instead of the
     * one we thought we were canceling.  Note we don't actually expect this
     * read to obtain any data, we are just waiting for EOF to be signaled.

which means that by the time the PQcancel call returns, the SIGINT has
been sent.  I did speculate upthread that delivery of that signal might
be asynchronous, but that was just speculation.  Even if there was some
delay, the backend would ignore the signal unless it arrived later than
the first byte of the next client request.  So it seems a bit hard to
credit that you would have a practical problem unless your application
were to issue a new command while PQcancel was still executing ... and if
it does, I maintain that's an application bug not a protocol problem.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (7+ messages)  latest in thread

Message-ID: <31145.1438185627@sss.pgh.pa.us>
Permalink:  ../31145.1438185627@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/31145.1438185627@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, niallfr@btinternet.com, kgrittn@ymail.com
  Subject: Re: BUG #13518: CancelRequest lacks statement identifier
  In-Reply-To: <31145.1438185627@sss.pgh.pa.us>
  References: <20150724180236.2737.27011@wrigleys.postgresql.org> <773925395.3977925.1438112478191.JavaMail.yahoo@mail.yahoo.com> <26896.1438113446@sss.pgh.pa.us> <55B7F554.7040700@btinternet.com> <31145.1438185627@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox