Re: Duplicate key error

From: Ron <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Duplicate key error
Date: 2021-03-04 06:57:57
Message-ID: 19beef53-95f4-672a-deda-41e236b03e38@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 3/4/21 12:14 AM, Andrus wrote:
> 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 ?
>

Having all the processes which try to update that table explicitly set a
serializable transaction would probably eliminate the duplicate key error. 
There's no free lunch, though: you'd have to handle the blocking.

--
Angular momentum makes the world go 'round.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Mathias Zarick 2021-03-04 10:34:19 RE: problems with my community account on www.postgresql.org
Previous Message Andrus 2021-03-04 06:14:18 Re: Duplicate key error