Re: Cancelling idle in transaction state

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: Kris Jurka <books(at)ejurka(dot)com>, Joachim Wieland <joe(at)mcknight(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hannu Krosing <hannu(at)2ndquadrant(dot)com>, James Pye <lists(at)jwp(dot)name>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Cancelling idle in transaction state
Date: 2009-12-30 12:15:30
Message-ID: 4B3B4462.4020704@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Simon Riggs wrote:
> On Wed, 2009-12-30 at 05:02 -0500, Kris Jurka wrote:
>> On Tue, 29 Dec 2009, Simon Riggs wrote:
>>
>>>> The proposal is to send an additional NOTICE to the client and abort
>>>> all open transactions and subtransactions (this is what I got from the
>>>> previous discussion).
>>> Would this work with JDBC driver and/or general protocol clients?
>>>
>> A Notice would be easy to overlook. The JDBC driver wraps that as a
>> SQLWarning which callers need to explicitly check for (and rarely do in my
>> experience). So when they run their next statement they'll get an error
>> saying that the current transaction is aborted, but they'll have no idea
>> why as the warning was silently eaten. I'd prefer the transaction
>> cancellation to come as an Error because that's what it really is.
>
> I'm not certain of all of these points, but here goes:
>
> AFAIK, NOTICE was suggested because it can be sent at any time, whereas
> ERRORs are only associated with statements.
>
> http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-ASYNC
> "It is possible for NoticeResponse messages to be generated due to
> outside activity; for example, if the database administrator commands a
> "fast" database shutdown, the backend will send a NoticeResponse
> indicating this fact before closing the connection. Accordingly,
> frontends should always be prepared to accept and display NoticeResponse
> messages, even when the connection is nominally idle."

Could we send an asynchronous notification immediately when the
transaction is cancelled, but also change the error message you get in
the subsequent commands. Clients that ignore the async notification
would still see a proper error message at the ERROR.

Something like:

ERROR: current transaction was aborted because of conflict with
recovery, commands ignored until end of transaction block

instead of the usual "current transaction is aborted, commands ignored
until end of transaction block" message.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2009-12-30 12:23:24 Re: solution to make static changes in pg_hba.conf file?
Previous Message Simon Riggs 2009-12-30 12:04:46 Re: Cancelling idle in transaction state