From: Andrei Zhidenkov <andrei.zhidenkov@n26.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: pg_cancel_backend() doesn't abort a transaction
Date: Thu, 11 Jun 2020 11:04:30 +0200
Message-ID: <0DCAFE79-5C75-41EE-9E40-9EF5293E73E4@n26.com> (raw)
In-Reply-To: <CAKFQuwaG8kft59TMs7DNBcstQb_-RjXNBY14kst8BiMyWuHTug@mail.gmail.com>
References: <CAKtDQ6D8m6MGjaMdXKv5p3PNbDSHGEPp_mieWOxAY9j_0WVdgQ@mail.gmail.com>
<CAKFQuwaG8kft59TMs7DNBcstQb_-RjXNBY14kst8BiMyWuHTug@mail.gmail.com>
With that said, it looks like the commentary for StatementCancelHandler() is not accurate.
> On 10. Jun 2020, at 17:09, David G. Johnston <david.g.johnston@gmail.com> wrote:
>
> On Wednesday, June 10, 2020, Andrei Zhidenkov <andrei.zhidenkov@n26.com <mailto:andrei.zhidenkov@n26.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.
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: andrei.zhidenkov@n26.com, david.g.johnston@gmail.com
Subject: Re: pg_cancel_backend() doesn't abort a transaction
In-Reply-To: <0DCAFE79-5C75-41EE-9E40-9EF5293E73E4@n26.com>
References: <CAKtDQ6D8m6MGjaMdXKv5p3PNbDSHGEPp_mieWOxAY9j_0WVdgQ@mail.gmail.com> <CAKFQuwaG8kft59TMs7DNBcstQb_-RjXNBY14kst8BiMyWuHTug@mail.gmail.com> <0DCAFE79-5C75-41EE-9E40-9EF5293E73E4@n26.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox