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 1lHhFo-0000hm-TV for pgsql-general@arkaria.postgresql.org; Thu, 04 Mar 2021 06:14:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lHhFn-0003v7-6r for pgsql-general@arkaria.postgresql.org; Thu, 04 Mar 2021 06:14:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lHhFm-0003uz-Ko for pgsql-general@lists.postgresql.org; Thu, 04 Mar 2021 06:14:30 +0000 Received: from portal-smtp-out.hot.ee ([194.126.101.125]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lHhFj-0000b5-BD for pgsql-general@postgresql.org; Thu, 04 Mar 2021 06:14:29 +0000 Received: from localhost (localhost [127.0.0.1]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 3D3D01DB0; Thu, 4 Mar 2021 08:14:24 +0200 (EET) X-Virus-Scanned: Debian amavisd-new at vm-hot-relay10.estpak.ee Received: from portal-smtp-out.hot.ee ([127.0.0.1]) by localhost (vm-hot-relay10.estpak.ee [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KBrzg8DG-ZKw; Thu, 4 Mar 2021 08:14:22 +0200 (EET) Received: from mail.hot.ee (hot-relayhost3.estpak.ee [213.180.2.81]) by vm-hot-relay10.estpak.ee (Postfix) with ESMTP id 08C5A1CB5; Thu, 4 Mar 2021 08:14:22 +0200 (EET) Subject: Re: Duplicate key error To: Adrian Klaver , pgsql-general@postgresql.org References: <5b68b4b3-b957-5009-cf3e-4bbc9dcbd0d9@aklaver.com> <97577cda-b3fa-4edb-1c8a-2b39afad65c6@hot.ee> From: Andrus Message-ID: <6a9dcf88-7b28-3b8f-0a1a-8a163f45a2a8@hot.ee> Date: Thu, 4 Mar 2021 08:14:18 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------736426488F5365FACBCD74FA" Content-Language: et List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------736426488F5365FACBCD74FA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi! > says something else is inserting/updating using that key value. So > obviously your script is not catching all the conflicts. > At this point your best bet is to monitor the Postgres log and see what else is happening at the time of the error. I'm guessing you will find another process working on that table. It looks like other process has added same row during trancaction. How to change script so that it works starting at Postgres 9.0 and does not cause error in this case ? Andrus. --------------736426488F5365FACBCD74FA Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit Hi!
says something else is inserting/updating using that key value. So obviously your script is not catching all the conflicts.

> At this point your best bet is to monitor the Postgres log and see what else is happening at the time of the error. I'm guessing you will find another process working on that table.

It looks like other process has added same row during trancaction.

How to change script so that it works starting at Postgres 9.0 and does not cause error in this case ?

Andrus.

--------------736426488F5365FACBCD74FA--