pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrus <kobruleht2@hot.ee>
To: Michael Lewis <mlewis@entrata.com>
Cc: Adrian Klaver <adrian.klaver@aklaver.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Duplicate key error
Date: Thu, 4 Mar 2021 21:46:32 +0200
Message-ID: <516197f2-545a-db36-3f5c-caa766c63a0c@hot.ee> (raw)
In-Reply-To: <CAHOFxGqnSL7zkQi89cowomqTQtiEMtULSa=Q54bp82HQB7yM2g@mail.gmail.com>
References: <a8656d4f-d692-ffae-077e-304f348e25bf@hot.ee>
	<5b68b4b3-b957-5009-cf3e-4bbc9dcbd0d9@aklaver.com>
	<97577cda-b3fa-4edb-1c8a-2b39afad65c6@hot.ee>
	<c22a9fa0-9f3a-8b68-c1d4-a430cf7286bc@aklaver.com>
	<abc069b9-5e92-b461-f215-68ad67a533b6@hot.ee>
	<d669cc09-aa93-cdf3-5030-37318d2a9001@aklaver.com>
	<6a9dcf88-7b28-3b8f-0a1a-8a163f45a2a8@hot.ee>
	<6cdec299-a677-03c4-2c8e-36560e052c9e@aklaver.com>
	<8bd1ce20-a369-7adf-2bb5-20fb6742c232@hot.ee>
	<CAHOFxGqhRnBs5nSJAoFJ_7rVNmroWXjdfZ+gkxn9y6rYRJ92_w@mail.gmail.com>
	<65ad98da-fae5-83e1-6cf2-abe6fc513961@hot.ee>
	<CAHOFxGqnSL7zkQi89cowomqTQtiEMtULSa=Q54bp82HQB7yM2g@mail.gmail.com>

Hi!

 >I just meant a regular update (which might impact 0 rows) and then 
insert (not exists) like you are doing already.

This causes duplicate key exception if other process adds same row to 
table at same time.

>
> >--transaction still ways. Should manual locking used or is there 
> better method.
> >I don't follow what you mean.

Allow access to this table for single transaction only. Wait for 
exclusive lock , do update/insert, release exclusive lock.

Andrus.

view thread (22+ messages)  latest in thread

Message-ID: <516197f2-545a-db36-3f5c-caa766c63a0c@hot.ee>
Permalink:  ../516197f2-545a-db36-3f5c-caa766c63a0c@hot.ee/
Also on:    postgresql.org/message-id/516197f2-545a-db36-3f5c-caa766c63a0c@hot.ee

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-general@postgresql.org
  Cc: kobruleht2@hot.ee, mlewis@entrata.com, adrian.klaver@aklaver.com
  Subject: Re: Duplicate key error
  In-Reply-To: <516197f2-545a-db36-3f5c-caa766c63a0c@hot.ee>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox