Re: pg_cancel_backend() doesn't abort a transaction

From: Andrei Zhidenkov <andrei(dot)zhidenkov(at)n26(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_cancel_backend() doesn't abort a transaction
Date: 2020-06-11 09:04:30
Message-ID: 0DCAFE79-5C75-41EE-9E40-9EF5293E73E4@n26.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

With that said, it looks like the commentary for StatementCancelHandler() is not accurate.

> On 10. Jun 2020, at 17:09, David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
> On Wednesday, June 10, 2020, Andrei Zhidenkov <andrei(dot)zhidenkov(at)n26(dot)com <mailto:andrei(dot)zhidenkov(at)n26(dot)com>> wrote:
>
> The result is that status = 'y' WHERE foo = 1 , so Session 1 committed the transaction successfully. I am missing something or the commentary is vague?
>
> P.S. It's not clear from the documentation whether pg_cancel_backend() aborts transaction or not
>
> User-facing docs seem reasonably clear: “ Cancel a backend's current query. “
>
> It makes it so that current query fails, nothing more. If that query is part of a transaction it will typically cause subsequent statements to fail since the transaction is in an aborted state. However, if the transaction can cope with that statement failing, as your example does using savepoints, the transaction can continue onto normal completion.
>
> From what you say the source code comments seem to be written for the common case, but “query-cancel” should/does impact just a single query and does not target the transaction directly.
>
> It does not seem desirable that the containing transaction be affected directly nor surely does changing the behavior make sense at this point.
>
> David J.
>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Daniel Gustafsson 2020-06-11 09:59:20 Re: BUG #16484: pg_regress fails with --outputdir parameter
Previous Message Michael Paquier 2020-06-11 08:27:36 Re: BUG #16484: pg_regress fails with --outputdir parameter