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 1khfek-0002Ba-H1 for pgsql-admin@arkaria.postgresql.org; Tue, 24 Nov 2020 21:15:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1khfej-0003yL-GW for pgsql-admin@arkaria.postgresql.org; Tue, 24 Nov 2020 21:15:21 +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 1khfej-0003yE-8v for pgsql-admin@lists.postgresql.org; Tue, 24 Nov 2020 21:15:21 +0000 Received: from jakobs.com ([85.214.83.89] helo=rs.plausibolo.de) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1khfeh-0007Ga-49 for pgsql-admin@lists.postgresql.org; Tue, 24 Nov 2020 21:15:20 +0000 Received: from localhost (localhost [127.0.0.1]) by rs.plausibolo.de (Postfix) with ESMTP id B72543803D6; Tue, 24 Nov 2020 22:15:17 +0100 (CET) Received: from rs.plausibolo.de ([127.0.0.1]) by localhost (h2367442.stratoserver.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PiX7iT2xyLVS; Tue, 24 Nov 2020 22:15:17 +0100 (CET) Received: from [192.168.178.86] (p5b249d69.dip0.t-ipconnect.de [91.36.157.105]) by rs.plausibolo.de (Postfix) with ESMTPSA id 125213803BE; Tue, 24 Nov 2020 22:15:17 +0100 (CET) Subject: Re: ERROR : invalid transaction termination : PostgreSQL v12 To: pgsql-admin@lists.postgresql.org References: <7685663c-4fb4-2875-9164-a44007ca9568@jakobs.com> From: Holger Jakobs Message-ID: <783165ad-62f6-dad9-6aa9-814428e49743@jakobs.com> Date: Tue, 24 Nov 2020 22:15:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="NnTQibwqW80TgMDvX6Rmu8CgLPdUJURDH" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --NnTQibwqW80TgMDvX6Rmu8CgLPdUJURDH Content-Type: multipart/mixed; boundary="oJLwhXKp8rN87K777qMWBzBHEyw6jdM53"; protected-headers="v1" From: Holger Jakobs To: pgsql-admin@lists.postgresql.org Message-ID: <783165ad-62f6-dad9-6aa9-814428e49743@jakobs.com> Subject: Re: ERROR : invalid transaction termination : PostgreSQL v12 References: <7685663c-4fb4-2875-9164-a44007ca9568@jakobs.com> In-Reply-To: --oJLwhXKp8rN87K777qMWBzBHEyw6jdM53 Content-Type: multipart/alternative; boundary="------------6D195FD3717D1D3577A3CC0C" Content-Language: de-DE This is a multi-part message in MIME format. --------------6D195FD3717D1D3577A3CC0C Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable So what is the intended behaviour? * If you run everything in autocommit, it will be very slow, but all non-failing records will end up in the table alright. * If you run a commit after a couple of records, you will lose all records of this group if there is at least one failing record. is that what you want? Oracle's behaviour of saving all non-failing records while discarding=20 all failing records is not directly possible with PostgreSQL, because=20 the sense of a transaction is all-or-nothing. Am 24.11.20 um 16:39 schrieb David G. Johnston: > On Tue, Nov 24, 2020 at 12:57 AM Holger Jakobs > wrote: > > What is the point of COMMITting after a few records? Why not let > the whole batch run through. If there are any errors, PostgreSQL > will rollback the whole transaction anyway. > > Avoiding that behavior is the point of batching with periodic commits. > > David J. > --=20 Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012 --------------6D195FD3717D1D3577A3CC0C Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

So what is the intended behaviour?

  • If you run everything in autocommit, it will be very slow, but all non-failing records will end up in the table alright.
  • If you run a commit after a couple of records, you will lose all records of this group if there is at least one failing record.
    is that what you want?

Oracle's behaviour of saving all non-failing records while discarding all failing records is not directly possible with PostgreSQL, because the sense of a transaction is all-or-nothing.

Am 24.11.20 um 16:39 schrieb David G. Johnston:
On Tue, No= v 24, 2020 at 12:57 AM Holger Jakobs <holger@jakobs.com> wrote:

What is th= e point of COMMITting after a few records? Why not let the whole batch run through. If there are any errors, PostgreSQL will rollback the whole transaction anyway.<= /font>

Avoiding that behavior is the point of batching with periodic commits.

David J.

--=20
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012
--------------6D195FD3717D1D3577A3CC0C-- --oJLwhXKp8rN87K777qMWBzBHEyw6jdM53-- --NnTQibwqW80TgMDvX6Rmu8CgLPdUJURDH Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wmMEABEIACMWIQScuJCxWJK1p5BOebGKV5yTsxlhugUCX7134wUDAAAAAAAKCRCKV5yTsxlhumhk AKC5HOdjB0OVPVnxkfLaLjyAyuTbaACgm0sO/xCMsNrmoZw4o2moqy1sE/0= =iJSu -----END PGP SIGNATURE----- --NnTQibwqW80TgMDvX6Rmu8CgLPdUJURDH--