Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jjJ8X-0003WW-Si for pgsql-bugs@arkaria.postgresql.org; Thu, 11 Jun 2020 09:04:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jjJ8W-0000jo-Of for pgsql-bugs@arkaria.postgresql.org; Thu, 11 Jun 2020 09:04:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jjJ8W-0000jP-GV for pgsql-bugs@lists.postgresql.org; Thu, 11 Jun 2020 09:04:36 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jjJ8U-0001Ek-6q for pgsql-bugs@lists.postgresql.org; Thu, 11 Jun 2020 09:04:36 +0000 Received: by mail-wm1-x329.google.com with SMTP id k26so4264179wmi.4 for ; Thu, 11 Jun 2020 02:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=n26.com; s=google; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=Gdera3cWzi+IiyqXgZBnkpBRd4bKnlAZ0G18mB3q4Q4=; b=FstMOdSuUucu1N61350G6G2lXnZ9GDthg5PRHCLlvJCUuw0K3shCZ9/STxpXoMe4kS 5DYCHYRIj6FokTztkadAKOaTLsiFqhr/GLLMlaXXR/MMpUd57/ejhD43ueUTLeOhKdi/ mElg965FoQHLqL0n4ir74nCXwEhnmu0ozoXo5CzWpF3vD62VHT+PCoC8jyB23Z1PG+tB O/KWvb7eUn9GD+i9M841F5B85D+ERcn9yoqyoE5tvVED6BpLEVVCg/UX5V+RtAWmsQaA WTNCXExNPKZ3c4BCBmgmT/4bSH9cKb6JZlYCTAsLUYj0YOUjyVZy41n8wCt9Akl+HVNi +sMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=Gdera3cWzi+IiyqXgZBnkpBRd4bKnlAZ0G18mB3q4Q4=; b=NAg5WASQp2vXdWVUbi8j/vpSXFCt/7I6LXUFjVrzHiztmS8PO0gnMW9FwVhucwUvZy qXq84Qsh3J/bp4Y6U/ohBkHYX+2AZglgKsVn0Sf5aroxFnAdpKvuAhSXka1nY34ocVlX F5V4N7lUN05zstQDRscMtVeO/w6qHrwcq1YKZBq+W58e1CbsOxP7ztXjVcNyqp5Qdoeu VlqKVe4t19jDbnHKdMPB75lV86Nj3khAKtHEkJknsMdHvei3T2dJyVVEgHbwSau50AGb 3MKTABi77isjbN2gYv+YfI9pPgOW7a1WtKkaOYbsNRxEQFS0pcL1EQzGCAFWLbF7R7bi vlNA== X-Gm-Message-State: AOAM532W3YDGFuOEacIzcmtLaPbWya3xTpqIx9E2oFXjDMKqJ6BBBLgS I6PDWgDlfCVFAIa4YQecwebhHQ== X-Google-Smtp-Source: ABdhPJws6qlG4yr4ZPD7LOEzAaxuuyDLVUXbVTOJv2ic6rNFQADYcFh97DJYY6jZR9cDhbIs3gm29A== X-Received: by 2002:a05:600c:210:: with SMTP id 16mr7603774wmi.185.1591866272092; Thu, 11 Jun 2020 02:04:32 -0700 (PDT) Received: from ip-10-1-200-6.eu-central-1.compute.internal (ec2-18-194-230-71.eu-central-1.compute.amazonaws.com. [18.194.230.71]) by smtp.gmail.com with ESMTPSA id 138sm3533716wma.23.2020.06.11.02.04.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Jun 2020 02:04:31 -0700 (PDT) From: Andrei Zhidenkov Message-Id: <0DCAFE79-5C75-41EE-9E40-9EF5293E73E4@n26.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_1D42960C-619F-4B7E-B20A-45A60B0227E9" Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3601.0.10\)) Subject: Re: pg_cancel_backend() doesn't abort a transaction Date: Thu, 11 Jun 2020 11:04:30 +0200 In-Reply-To: Cc: "pgsql-bugs@lists.postgresql.org" To: "David G. Johnston" References: X-Mailer: Apple Mail (2.3601.0.10) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_1D42960C-619F-4B7E-B20A-45A60B0227E9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 With that said, it looks like the commentary for = StatementCancelHandler() is not accurate. > On 10. Jun 2020, at 17:09, David G. Johnston = wrote: >=20 > On Wednesday, June 10, 2020, Andrei Zhidenkov = > wrote: >=20 > The result is that status =3D 'y' WHERE foo =3D 1 , so Session 1 = committed the transaction successfully. I am missing something or the = commentary is vague? >=20 > P.S. It's not clear from the documentation whether pg_cancel_backend() = aborts transaction or not >=20 > User-facing docs seem reasonably clear: =E2=80=9C Cancel a backend's = current query. =E2=80=9C >=20 > 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. >=20 > =46rom what you say the source code comments seem to be written for = the common case, but =E2=80=9Cquery-cancel=E2=80=9D should/does impact = just a single query and does not target the transaction directly. >=20 > It does not seem desirable that the containing transaction be affected = directly nor surely does changing the behavior make sense at this point. >=20 > David J. >=20 --Apple-Mail=_1D42960C-619F-4B7E-B20A-45A60B0227E9 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 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> wrote:

The result is that status =3D 'y' WHERE = foo =3D 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: =E2=80=9C Cancel a backend's current query. =E2=80=9C
<= div class=3D"">
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.

=46rom = what you say the source code comments seem to be written for the common = case, but =E2=80=9Cquery-cancel=E2=80=9D 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.


= --Apple-Mail=_1D42960C-619F-4B7E-B20A-45A60B0227E9--