pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Csaba Nagy <nagy@ecircle-ag.com>
Cc: ON.KG <skyer@on.kg>
Cc: Postgres general mailing list <pgsql-general@postgresql.org>
Subject: Re: duplicate key violates unique constraint
Date: Mon, 13 Jun 2005 16:49:15 +0100
Message-ID: <42ADAAFB.30404@archonet.com> (raw)
In-Reply-To: <1118676122.2720.24.camel@coppola.muc.ecircle.de>
References: <42A95936.3060002@archonet.com>
<20050610095655.0215752956@svr1.postgresql.org>
<10813889593.20050613202239@on.kg>
<42AD9B9D.6080902@archonet.com>
<1118676122.2720.24.camel@coppola.muc.ecircle.de>
Csaba Nagy wrote:
> [snip]
>
>>If you have more than one client, this can always happen. You have two
>>choices:
>> 1. Use a lock to stop two clients interacting like this
>
>
> This won't work unless you make all the clients serialized, or you have
> all the ip's already inserted in the data base... you can't lock on an
> unknown key, otherwise the locking will also need to insert, and you're
> back to the same race condition ;-)
You can, however, have something more finely-grained than whole-table
locking (assuming one IP updated/inserted at a time) by filling a dummy
table with e.g. integers 0..255 and locking a row there based on (e.g.)
the last octet of your target IP.
--
Richard Huxton
Archonet Ltd
view thread (17+ messages) latest in thread
Message-ID: <42ADAAFB.30404@archonet.com> Permalink: ../42ADAAFB.30404@archonet.com/ Also on: postgresql.org/message-id/42ADAAFB.30404@archonet.com ·
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-sql@postgresql.org Cc: dev@archonet.com, nagy@ecircle-ag.com, skyer@on.kg, pgsql-general@postgresql.org Subject: Re: duplicate key violates unique constraint In-Reply-To: <42ADAAFB.30404@archonet.com> * 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