Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1snIAa-002RjT-88 for pgsql-general@arkaria.postgresql.org; Sun, 08 Sep 2024 13:41:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1snIAZ-00ETE2-5u for pgsql-general@arkaria.postgresql.org; Sun, 08 Sep 2024 13:41:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1snIAY-00ETDp-Mw for pgsql-general@lists.postgresql.org; Sun, 08 Sep 2024 13:41:34 +0000 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1snIAU-0009CS-Af for pgsql-general@lists.postgresql.org; Sun, 08 Sep 2024 13:41:33 +0000 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a8b155b5e9eso262922166b.1 for ; Sun, 08 Sep 2024 06:41:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20230601.gappssmtp.com; s=20230601; t=1725802890; x=1726407690; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=no59uPeuohbOu6j46GDk5pZ+skEjDEncgud3vrVe4zg=; b=yx6ZoZ+lfGmIFcsyZZE+oI61eMOhmCmdh4sYbmXLwUWjq62zGTZWIBBmb5XqR7PhTY LDx6Qfu/vagWOFcByav/qX4vbT5mm6tTjOeyBTgFsA/zIOfIfXXSOQet+czXvrO1GUJ4 QTxGcZtGN7sqtvWIEifp0fIuCz9xJFN/u93S07CS/56BH5taQ7JeshgByF84WthjqVsa z9+CiYw8pvEtxhquIJ4kONbxTxXu/sPvYqFR6N2CSyehZsu2cN6QKci6jao61rHHgjs1 YPsfnvB8Qx47fWeBlT+O9fWacW98dPNvhm0xWwsYbQMNW+U6QBqlvSV3VDMGmJ/IG1xc jjmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725802890; x=1726407690; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=no59uPeuohbOu6j46GDk5pZ+skEjDEncgud3vrVe4zg=; b=O7ZrxEung0ky54wtHFvo8ETweYuSmHjs7Hv28FHn5ZA1AAIDwuCC0NgRm0bkQVwoYB 0PYLDq7WhrCntyqO1HqZSXfXJko0lj4l8rgyK0isDpeCVjZ5EYkAAGDTqRUcpT5NpeDN DyhUBDeLHsYk/9DRBUTNmjgrXPr5Clk/BVnicgZzDtUpvh99XN5Zqa9iSpg/kuZCO0zp Ifi4yv6NXyu0DUx18bwINxK1EqO8DAHDtnPBy5q7Ui56Sxqq50954PLkuVd94X4gOWcX 0hyRiq03/Ys7QLFbOvhZzrdc61r262GdrYmcHoH2aqVTXK6sBnXYfiMIyWbEc2JDzitT ds/w== X-Gm-Message-State: AOJu0YzgjUXCxhWQX7MQTf6zjQxCc/ZDTrV5qZzYZ7DbyAir4CpbMShf r4XNlOHx2pYDX9osXSzqG16Icd01nPEyxkfYkcmamlWefcnKQRlDQoP5HrKH55A= X-Google-Smtp-Source: AGHT+IEd16Afdq1MZmxghklHZgVYSsDiLY2zvvABzvxYF3QNN3lI7xr9sN3vP4CJ+uCWofmIKhrlUw== X-Received: by 2002:a17:907:3e9e:b0:a7a:9ca6:528 with SMTP id a640c23a62f3a-a8a885be29fmr597152966b.11.1725802889519; Sun, 08 Sep 2024 06:41:29 -0700 (PDT) Received: from [10.0.3.10] ([213.235.133.41]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8d258338a2sm205183866b.43.2024.09.08.06.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Sep 2024 06:41:29 -0700 (PDT) Message-ID: <1643e5dbd663bbbc8f2458c8dab08da342529643.camel@cybertec.at> Subject: Re: How to cleanup transaction after statement_timeout aborts a query? From: Laurenz Albe To: Istvan Soos Cc: pgsql-general@lists.postgresql.org Date: Sun, 08 Sep 2024 15:41:03 +0200 In-Reply-To: References: <8fabad5643b3b10355c95e30f4e758c17640d0d0.camel@cybertec.at> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.4 (3.52.4-1.fc40) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, 2024-09-08 at 15:01 +0200, Istvan Soos wrote: > On Sun, Sep 8, 2024 at 1:19=E2=80=AFPM Laurenz Albe wrote: > > ROLLBACK and COMMIT are working: they end the transaction. >=20 > I have this reproduction test, and ROLLBACK does fail: > https://github.com/isoos/postgresql-dart/pull/363/files#diff-4547e49b04ec= 8280fb8f4f1ebf695b77f9a2d9a4ac9bcfd685bcd570a46baa80R122 >=20 > I've checked and nothing else is sent on the protocol, yet, for the > rollback statement it gets the 25P02 error. You must be doing something wrong then, because it works: test=3D> START TRANSACTION; START TRANSACTION test=3D*> SELECT 1 / 0; ERROR: division by zero test=3D!> SELECT 42; ERROR: current transaction is aborted, commands ignored until end of trans= action block test=3D!> SELECT 42; ERROR: current transaction is aborted, commands ignored until end of trans= action block test=3D!> ROLLBACK; ROLLBACK test=3D>=20 >=20 > > To handle the failure of a statement while allowing the transaction to = proceed, > > you can use savepoints. But be warned: don't even think of setting a s= avepoint > > before each statement. That would affect statement performance severel= y. >=20 > As the writer of the client library, I don't have the luxury of > telling users they need to change their way, hence I'm looking for any > pointer on the protocol level. I understand. But there is no way to influence this behavior. Perhaps the best option for your library is not to try to "mask" the way Po= stgreSQL behaves in this case. It is then up to the users of the library to do the = right thing. Yours, Laurenz Albe