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

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Naoya Anzai <anzai-naoya(at)mxu(dot)nes(dot)nec(dot)co(dot)jp>
Cc: "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: 2014-06-08 06:52:46
Message-ID: CAA4eK1L7xA1CgscQTSq9v3GBmW3cyQhiUerSdDr08o8EXoRyqA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jun 6, 2014 at 2:11 PM, Naoya Anzai <anzai-naoya(at)mxu(dot)nes(dot)nec(dot)co(dot)jp>
wrote:
>
> Hi All,
>
> When log_duration is true ( or log_min_duration_statement>=0 ),
> If a transaction has internally been commited receives a SIGINT signal
> then a query cancellation error is output.
>
> For example,
> 1. A query like a TRUNCATE is removing bigger table files.
> 2. The session receives SIGINT signal.
> 3. Query cancellation error occurs.
> 4. But the query has commited.
>
>
> naoya=# truncate hoge;
> Cancel request sent
> ERROR: canceling statement due to user request
> naoya=# select count(*) from hoge;
> count
> -------
> 0
> (1 row)
> ---
>
> This is because ProcessInterrupts function is called by errfinish ( in
query-duration ereport).
>
> I think this cancellation request must not interrupt the internal
commited transaction.
>
> This is because clients may misunderstand "the transaction has
rollbacked".

There can be similar observation if the server goes off (power
outage or anything like) after committing transaction, client will
receive connection broken, so he can misunderstand that as well.
I think for such corner cases, client needs to reconfirm his action
results with database before concluding anything.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2014-06-08 07:24:28 Re: Proposing pg_hibernate
Previous Message Amit Kapila 2014-06-08 06:40:02 Re: avoiding tuple copying in btree index builds