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: 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: 2010-01-01 10:53:56
Message-ID: 4B3DD444.8040908@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Simon Riggs wrote:
> Attached is the patch I intend to commit, barring objections.
>
> This patch extends SIGINT to allow cancellation of transactions while
> idle in both HS and normal mode.

How does AbortTransactionAndAnySubtransactions() differ from
AbortOutOfAnyTransaction()? Having followed the discussions on this
patch I think I know the answer: I'm guessing that
AbortTransactionAndAnySubtransactions() leaves the backend in aborted
state, while AbortOutOfAnyTransaction() leaves it in idle state. It
would be good to point that out more clearly in the comment above
AbortTransactionAndAnySubtransactions().

I agree with Joachim's comments upthread that we should have a different
function for forcefully aborting the whole transaction, and leave the
current pg_cancel_backend() behavior alone. In any case, the
documentation of pg_cancel_backend() or the new function needs to
explain what exactly it does.

I believe people liked the idea of giving a different ERROR message when
a transaction is canceled because of conflict with recovery. It would
also be good to give a different error message when an idle transaction
is canceled using query cancel. Otherwise you don't know what hit you,
especially if you're not paying attention to NOTICEs.

> It also changes the standard message
> reported on an idle transaction in aborted state to '<IDLE> in
> transaction (aborted)', so that once aborted we keep the message even if
> the user tries to issue further statements other than ROLLBACK or
> COMMIT.

That's nice.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2010-01-01 14:48:26 Re: Cancelling idle in transaction state
Previous Message Dimitri Fontaine 2010-01-01 09:41:38 Re: PATCH: Add hstore_to_json()