Re: "cancelling statement due to user request error" occurs but the transaction has committed.

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Naoya Anzai <anzai-naoya(at)mxu(dot)nes(dot)nec(dot)co(dot)jp>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Akio Iwaasa <iwaasa(at)mxs(dot)nes(dot)nec(dot)co(dot)jp>
Subject: Re: "cancelling statement due to user request error" occurs but the transaction has committed.
Date: 2015-03-20 00:57:00
Message-ID: 20150320005659.GF20462@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 19, 2015 at 08:43:52PM -0400, Tom Lane wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> writes:
> > On Thu, Mar 19, 2015 at 06:59:20PM -0300, Alvaro Herrera wrote:
> >> I don't understand why aren't interrupts held until after the commit is
> >> done -- including across the mentioned ereports.
>
> > Uh, I think Robert was thinking of pre-commit triggers at the top of
> > CommitTransaction() that might take a long time and we might want to
> > cancel.
>
> Yeah, that's a good point. So really the only way to make this work as
> requested is to have some cooperation between xact.c and postgres.c,
> so that the hold taken midway through CommitTransaction is kept until
> we reach the idle point.
>
> The attached is only very lightly tested but shows what we probably
> would need for this. It's a bit messy in that the API for
> CommitTransactionCommand leaves it unspecified whether interrupts are
> held at exit; I'm not sure if it's useful or feasible to be more precise.

Oh, I see what you are saying, and why a global variable will not work.
I thought all paths reset the cancel state when the returned from a
commit, but it seems there are many places that don't do reset, so you
have to pass a flag down into CommitTransaction() to control that ---
makes sense.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ Everyone has their own god. +

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2015-03-20 01:05:52 Re: proposal: doc: simplify examples of dynamic SQL
Previous Message Kouhei Kaigai 2015-03-20 00:52:19 Re: GSoC - Idea Discussion