Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZKB10-0001FY-DL for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Jul 2015 19:58:18 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZKB0z-0004S7-Qm for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Jul 2015 19:58:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZKB0M-0003Ls-Nn for pgsql-bugs@postgresql.org; Tue, 28 Jul 2015 19:57:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZKB0F-0003RG-JU for pgsql-bugs@postgresql.org; Tue, 28 Jul 2015 19:57:38 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t6SJvQ2G026897; Tue, 28 Jul 2015 15:57:26 -0400 From: Tom Lane To: Kevin Grittner cc: "niallfr@btinternet.com" , "pgsql-bugs@postgresql.org" Subject: Re: BUG #13518: CancelRequest lacks statement identifier In-reply-to: <773925395.3977925.1438112478191.JavaMail.yahoo@mail.yahoo.com> References: <20150724180236.2737.27011@wrigleys.postgresql.org> <773925395.3977925.1438112478191.JavaMail.yahoo@mail.yahoo.com> Comments: In-reply-to Kevin Grittner message dated "Tue, 28 Jul 2015 19:41:18 -0000" Date: Tue, 28 Jul 2015 15:57:26 -0400 Message-ID: <26896.1438113446@sss.pgh.pa.us> X-Pg-Spam-Score: -3.3 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Kevin Grittner writes: > "niallfr@btinternet.com" wrote: >> If CancelRequest could include a statement name (or other means >> of identifying a statement) and did nothing if that statement was >> no longer running by the time the server processed it, the >> usability of CancelRequest would be significantly enhanced. > Would it be sufficient for your purposes to cancel a *transaction* > rather than a *statement*? There is already a virtual transaction > ID exposed in pg_locks, and it could probably be added to > pg_stat_activity; we could probably create a > pg_cancel_transaction() function that took a text representation of > that and only canceled the transaction if it was running. There > would need to be locking on a heavily contended lock or two to make > that happen correctly, but presumably this would not ba a > high-volume activity. If I'm correctly visualizing what you've got in mind, it seems like that would only narrow the race-condition window not close it entirely. I don't believe there's any guarantee that signals-in-flight are delivered immediately, so the SIGINT might still arrive at the target process after it's finished out the transaction that was meant to be canceled. The bigger picture though is that what you're suggesting would require that a whole new connection be made in order to issue a Cancel. That's kind of an expensive solution ... not that what we're doing now is exactly free, but at least it doesn't fail if you're up against the MaxBackends limit, for instance. 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